You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When pino-pretty is used together with elastic formatting the logging level has log.level key in the log object. I found no way to make pino-pretty work correctly with this level key.
In version 9 pino-pretty allowed dot in key names without escaping while in version 10 we need to escape it with slashes.
This would be ok but this escaping breaks excluding this key from the message string.
Example (uncomment levelKey with/without escaping to see different havaviours):
constpino=require('pino');constpretty=require('pino-pretty');constecsFormat=require('@elastic/ecs-pino-format');constoptions=ecsFormat({});options.level='debug';constlogger=pino(options,pretty({colorize: true,singleLine: true,levelKey: 'log\\.level',// if levelKey dot is escaped then log.level appears at the console output// levelKey: 'log.level', // if levelKey dot is not escaped then level is not showing between messagetimestampKey: '@timestamp',messageKey: 'message',ignore: 'service,process,host,ecs'}));logger.info('Starting');logger.debug({extraParam: '123',message: 'hello hello'});
The example output is
As you can see the output contains unwanted "log.level":"info" and "log.level":"debug".
If I remove dot escaping then the output changes to
Ths time it has no colored INFO and DEBUG levels.
The text was updated successfully, but these errors were encountered:
When pino-pretty is used together with elastic formatting the logging level has
log.level
key in the log object. I found no way to make pino-pretty work correctly with this level key.In version 9 pino-pretty allowed dot in key names without escaping while in version 10 we need to escape it with slashes.
This would be ok but this escaping breaks excluding this key from the message string.
Example (uncomment levelKey with/without escaping to see different havaviours):
The example output is
As you can see the output contains unwanted
"log.level":"info"
and"log.level":"debug"
.If I remove dot escaping then the output changes to
Ths time it has no colored
INFO
andDEBUG
levels.The text was updated successfully, but these errors were encountered: