bithavoc / express-winston

express.js middleware for winstonjs
https://www.npmjs.com/package/express-winston
MIT License
795 stars 187 forks source link

winston-mongodb - meta always null #239

Closed MarErnest closed 4 years ago

MarErnest commented 4 years ago

Issue: Meta is always null, not saving in MongoDB

Logger Code

expressWinston.requestWhitelist.push('body');
expressWinston.responseWhitelist.push('body');

export const apiLogger = expressWinston.logger({
  transports,
  requestWhitelist: ['headers', 'query', 'body'],
  responseWhitelist: ['body'],
  meta: true
});

Console Transport Shows the Body

info: HTTP POST /test {"meta":{"req":{"headers":{"content-type":"application/json","user-agent":"PostmanRuntime/7.24.0","accept":"*/*","cache-control":"no-cache","postman-token":"22a9addf-7e74-4dcb-abe5-6e0d708ce9dc","host":"localhost:3000","accept-encoding":"gzip, deflate, br","connection":"keep-alive","content-length":"28","cookie":"session-token=173877e0-4dca-11e9-961b-35e38ecd3451"},"query":{},"body":{"Millie":"bobby brown"}},"res":{"body":{"Millie":"bobby brown"}},"responseTime":2}}