Closed jcald1 closed 5 years ago
JSON does not include undefined values. pino is a json logger, and as such we cannot include them.
@mcollina, would it make sense to optionally map them to null based on the pino configuration?
null
is a value in JavaScript whereas undefined
is equivalent to the property not being present at all. So I wouldn’t think it makes sense to remap undefined
to null
.
@jsumners , that is correct, but from a practical point of view, it is often useful in logging to know that a variable is undefined. I wonder if it would make sense to have some reserved property name that can be used to convey information that normally gets dropped in a conversion to JSON. Or to allow the user to have more control using more configuration options.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
If you execute:
log.info({ msg: 'test', msgUndefined: undefined })
pino logs:
{"level":30,"time":1553633517657,"pid":1,"hostname":"a8455c8d7d8b","msg":"test","v":1}
the properties with values of
undefined
are not logged. These should be logged, or at the very least the option to log them should be configurable.pino version: 5.11.3