koa2-winston
koa2-winston copied to clipboard
How to log a json body?
The document showing custom config didn't work.
transports: new winston.transports.Console({ json: true, stringify: true }),
Seems that the config is not being pickup.
Sorry about that.
Config in the readme it work for winston@2.
Documents for winston@3, link down here.
BTW, if you use default transport, it would log in json string.
@yidinghan Thanks for reply. This is by far the best logger suits the logging needs. I would like to log the json body of req and res. This is my configs.
app.use(logger({
reqSelect: ['body'],
resSelect: ['body']
}))
This is the console result I got
"body":{"user":"[object Object]"}}
is it possible to print the whole body to a json string?