Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to log a json body? #7

Open
jcyh0120 opened this issue Jan 28, 2019 · 2 comments
Open

How to log a json body? #7

jcyh0120 opened this issue Jan 28, 2019 · 2 comments

Comments

@jcyh0120
Copy link

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.

@yidinghan
Copy link
Owner

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.

@jcyh0120
Copy link
Author

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants