Closed gotmikhail closed 9 years ago
req.body
is by default not included because it will often contain things that shouldn't be logged like passwords, so be sure you want to do it before you do.
Since you have now been warned, you can add it by adding
expressWinston.requestWhitelist.push('body');
somewhere after loading expressWinston and before app.use
ing expressWinston.logger
.
Perfect!
Completely understand the danger of logging the req.body
. We have different transports defined just to handle things like passwords, plus the logging behaves differently based on whether NODE_ENV
is development or production.
Actually, trying it out I still haven't gotten it to successfully print req.body
.
Will the whitelist still work with the winstonInstance
option?
Here's a snippet of my code:
var expressWinston = require('express-winston');
Later in the code:
expressWinston.requestWhitelist.push('body');
app.use(expressWinston.logger({
winstonInstance: logHandler.logger
}));
No req.body
is sent to the log.
Logging out the req.body
myself, you get:
{
"user": {
"email": "m1@2.3"
}
}
Honestly, I haven't used this library much since 2012, so I'm kinda winging it. :) Try doing expressWinston. bodyWhitelist.push('user');
with and without the requestWhitelist; that might solve it.
I'm also experiencing this issue. I added these lines before adding in express-winston:
expressWinston.requestWhitelist.push('body');
expressWinston.requestWhitelist.push('session');
expressWinston.requestWhitelist.push('sessionID');
expressWinston.requestWhitelist.push('user');
expressWinston.bodyWhitelist.push('address');
expressWinston.bodyWhitelist.push('content');
expressWinston.bodyWhitelist.push('features');
Fixed now see #52 and #53
I haven't had luck in getting
req.body
to print out in the log.Here's what I'm getting: