bithavoc / express-winston

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

Omit stack + trace on errorLogger #157

Open weeco opened 6 years ago

weeco commented 6 years ago

I am trying to omit the stack and trace fields from my error log messages, however the documentation is a bit confusing.

What I've tried, which would still output stack + trace in the error log:

app.use(expressWinston.errorLogger({
  winstonInstance,
  showStack: false,
  showTrace: false,
}))

Quoted from your readme:

    // Optionally you can include your custom error handler after the logging.
    app.use(express.errorLogger({
      dumpExceptions: true,
      showStack: true
    }));

I couldn't find the "showStack" property documented anywhere so I simply tried to use showTrace: false too. However nor the showTrace or showStack property seem to affect anything. How can I achieve that the error messages don't contain the stack + trace anymore?

codingthat commented 3 years ago

I don't see dumpExceptions in the repo anywhere either with a GitHub search, and TS complains about it.

bithavoc commented 3 years ago

@codingthat I can't remember at the moment, but I believe that functionality was implemented by Winston itself, we only provide exceptionMeta option to convert an error to some metadata.

Readme is clearly outdated.

bithavoc commented 3 years ago

@codingthat Ok found it in the express.js 2.x docs at https://expressjs.com/2x/guide.html

app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
codingthat commented 3 years ago

Oh yeah, I had missed the express vs. expressWinston difference in @weeco 's original description, too.