我需要将记录器传输到记录错误和警告的文本文件。现在,我使用Winston进行控制台记录传输:
SELECT * FROM ART WHERE category=val OR subject=val OR medium=val;
答案 0 :(得分:1)
要在文件中记录跟踪,请尝试添加以下代码段
new (winston.transports.File)({ filename: 'somefile.log' });
添加logger
作业后,应该看起来像
logger = new winston.Logger({
transports: [
new (winston.transports.Console)({
name: 'info-console',
level: configLogging.level,
colorize: true,
timestamp: function() { return m.utc().format(dateFormat); }
}),
new (winston.transports.File)({ filename: 'somefile.log' })
]
});
logger.info('Starting logging service');
<强>更新强>
单独记录Errors
和Logs
请尝试使用
var logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
name: 'info-file',
filename: 'filelog-info.log',
level: 'info'
}),
new (winston.transports.File)({
name: 'error-file',
filename: 'filelog-error.log',
level: 'error'
})
]
});
希望这有帮助!