据我所了解,Winston在其日志级别中有一个层次结构。您可以使用
这段代码基本上来自于这个教程: http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
winston.level = 'error'
设置级别,并且所有低于该级别的级别都不应显示。不幸的是,我的控制台仍然显示info和debug的日志。
问题1:
如何真正设置winston只显示日志级别
问题2:
为什么调试仍然在控制台中显示,我已经将其配置为在日志文件中显示(此外还会这样做)
winston = require('winston')
winston.emitErrs = true
logger = new winston.Logger({
transports: [
new winston.transports.File({
level: 'info'
filename: 'logs/log.log'
handleExceptions: true
json: true
maxsize: 5242880 #5MB
maxFiles: 5
colorize: false
timestamp: true
}),
new winston.transports.Console({
level: 'debug'
handleExceptions: true
json: false
colorize: true
})
],
exitOnError: false
})
winston.level = 'error'
module.exports = logger
module.exports.stream = {
write: (message, encoding) ->
logger.info(message)
}
这段代码基本上来自于这个教程: http://tostring.it/2014/06/23/advanced-logging-with-nodejs/