【发布时间】:2017-03-23 11:11:59
【问题描述】:
我有两个不同的 winston 记录器,看起来像这样(有两个独立的记录器,因为它们根据我的功能编写不同的日志) - :
var security = new(winston.Logger)({
transports: [
new(require('winston-daily-rotate-file'))({
filename: logDir + '/-security.log',
datePattern: 'dd-MM-yyyy',
prepend: true,
json: false,
timestamp: function() {
return moment().format('D/MM/YYYY HH:mm:ss:SSS');
}
})
]
});
然后我还有一个:
var system = new(winston.Logger)({
transports: [
new(require('winston-daily-rotate-file'))({
filename: logDir + '/-security.log',
datePattern: 'dd-MM-yyyy',
prepend: true,
json: false,
timestamp: function() {
return moment().format('D/MM/YYYY HH:mm:ss:SSS');
}
})
]
});
但是,我还有一个verbose.log 文件,我希望将安全和系统日志文件中的所有日志也写入详细文件。最好的方法是什么?
我尝试将文件名(即verbose.log)添加到每个传输,但这不起作用,因为我收到错误
Error: Transport already attached: dailyRotateFile, assign a different name
【问题讨论】: