Search code examples
node.jswinston

Show uncaught exception in console when using winston (node.js)


Here's the code I'm working with:

 var winston = require('winston');
 winston.add(winston.transports.File, { filename: 'test.log', handleExceptions: true, humanReadableUnhandledException: true });
 throw "test";

In test.log, winston does log the error properly.

But I'd also like it to show the error in the console as well like it normally does.

Is this possible?


Solution

  • Add Console transport to winston, along with existing File transport:

     winston.add(winston.transports.Console, options)
    

    https://github.com/winstonjs/winston/blob/master/docs/transports.md#console-transport