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

Is it possible log all headers and body of request and response? #130

Closed
guseinovmg opened this issue Nov 10, 2016 · 2 comments
Closed

Is it possible log all headers and body of request and response? #130

guseinovmg opened this issue Nov 10, 2016 · 2 comments
Assignees
Labels

Comments

@guseinovmg
Copy link

No description provided.

@dougwilson
Copy link
Contributor

Yep, just add a custom token that returns what you want to log, and then set your format to include that token :) !

@dougwilson dougwilson self-assigned this Nov 10, 2016
@vit100
Copy link

vit100 commented Jan 9, 2020

I do it like this:

morgan.token('req-headers', function(req,res){
 return JSON.stringify(req.headers)
})

process.env.NODE_ENV != 'prod' && app.use(morgan(':method :url :status :req-headers'));

@expressjs expressjs locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants