winston.info('Hello again distributed logs', { app: 'test', sid: 1 })
pino.info('Hello again distributed logs', { app: 'test', sid: 1 })
Output:
{"app":"test","sid":1,"level":"info","message":"Hello again distributed logs","timestamp":"2017-02-16T03:34:06.186Z"}
{"pid":4269,"hostname":"Macchiato.local","level":30,"time":1487216046197,"msg":"Hello again distributed logs {\"app\":\"test\",\"sid\":1}","v":1}
I have fluentd daemon to pickup container stdout and ship it to cloudwatch.
In the example above, cloudwatchlogs can detect the metadata correctly from pino and I will be able to query the log like this
{$.app = "test"}
However, winston console is not working like that and everything got push to log attribute.
Does anyone know how to fix this. I'm using winston console with json: true and stringify: true
I concur with what @davidmarkclements said in https://github.com/pinojs/pino/issues/194#issuecomment-280676307
At a guess I'd say cloudwatch is parsing the
msgfield and then running the query agains the object found in themsgfield?
In [email protected] the default format was:
`${message} ${JSON.stringify(meta)`
so if you continue to use 2.x you want to use the { json: true } for your Console transport. If you upgrade to [email protected] JSON is the default transport so this will just work as is out of the box. 馃樃 馃樃 馃樃
Most helpful comment
I concur with what @davidmarkclements said in https://github.com/pinojs/pino/issues/194#issuecomment-280676307
In
[email protected]the default format was:so if you continue to use
2.xyou want to use the{ json: true }for yourConsoletransport. If you upgrade to[email protected]JSON is the default transport so this will just work as is out of the box. 馃樃 馃樃 馃樃