使用 winston 时在控制台中显示未捕获的异常 (node.js)
Show uncaught exception in console when using winston (node.js)
这是我正在使用的代码:
var winston = require('winston');
winston.add(winston.transports.File, { filename: 'test.log', handleExceptions: true, humanReadableUnhandledException: true });
throw "test";
在 test.log 中,winston 正确地记录了错误。
但我也希望它能像往常一样在控制台中显示错误。
这可能吗?
将控制台传输与现有文件传输一起添加到 winston:
winston.add(winston.transports.Console, options)
https://github.com/winstonjs/winston/blob/master/docs/transports.md#console-transport
这是我正在使用的代码:
var winston = require('winston');
winston.add(winston.transports.File, { filename: 'test.log', handleExceptions: true, humanReadableUnhandledException: true });
throw "test";
在 test.log 中,winston 正确地记录了错误。
但我也希望它能像往常一样在控制台中显示错误。
这可能吗?
将控制台传输与现有文件传输一起添加到 winston:
winston.add(winston.transports.Console, options)
https://github.com/winstonjs/winston/blob/master/docs/transports.md#console-transport