bithavoc / express-winston

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

WinstonLogger instance and request/response whitelist not working together #200

Closed vkyt closed 5 years ago

vkyt commented 5 years ago

I'm running into a weird issue with using WinstonLogger and whitelist request/response body

Following is what I'm trying to do

expressWinston.responseWhitelist.push('body')
app.use(expressWinston.logger({ winstonInstance: logger })) // logger is an object with custom winston logger format

However the response is not being logged, I had to get rid of the WinstonLogger instance for the whitelist to show up.

The following is what worked for me:

expressWinston.responseWhitelist.push('body')
app.use(expressWinston.logger({ transports: [
        new winston.transports.Console()
      ],
      format: winston.format.combine(
        winston.format.colorize()
        winston.format.json()
      )
 }))

I thought only transport and format options are affected when we use a WinstonLogger?

vkyt commented 5 years ago

Found an issue with the custom logger that was passed in that may have affected the logging - the use of humanReadableUnhandledException in winston transports seems to be the issue. Closing issue.