bithavoc / express-winston

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

errorLogger is not working #240

Open theromie opened 4 years ago

theromie commented 4 years ago

I am using express-routes-mapper for routes and I have expressWinston.logger({}) before app.use('abc/xyz', mappedOpenRoutes); and expressWinston.errorLogger({}) after app.use('abc/xyz', mappedOpenRoutes); but expressWinston.logger({}) showing in console but errorLogger is not showing error into file. I have error like ReferenceError: email is not defined but that is not being logged.

app.use( expressWinston.errorLogger({ transports: [ new winston.transports.Console(), new DailyRotateFile({ filename: '%DATE%-error.log', datePattern: 'DD-MM-YYYY', maxSize: '20480', zippedArchive: true, }), ], format: winston.format.combine( winston.format.colorize(), winston.format.json() ), msg: '{{err.message}}', }) );

MelodicCrypter commented 3 years ago

I'm also having this kind of scenario. Any updates on this one? Thanks!

crucialfelix commented 3 years ago

It posts the Errors console, but does not use JSON. So it is always only posting to console.

  app.use(
    // This is not posting as JSON in production
    expressWinston.errorLogger({
      transports: [new winston.transports.Console()],
      format: winston.format.combine(winston.format.json()),
   })
 )