当winston处理未捕获的异常时,它会输出未捕获的异常的一个很好的信息。我如何对“捕获的异常”执行相同的操作?如何记录“catched”异常?
if (err) {
// winston. log the catched exception
}
我检查了源和似乎有一个logException
method,但我不知道我怎么能使用它。
var logger = new winston.Logger({
transports: [new winston.transports.Console({handleExceptions: true})]
})
var err = new Error('test error.')
logger.logException(err.message) //no method 'logException'
也许这是从旧版本温斯顿的,但目前还没有这样的API。 https://github.com/winstonjs/winston – Seth 2017-03-09 12:30:46