是否可以只将快速写入访问行写入日志文件,并将其他日志保留在控制台中?像这样:
app.use(expressWinston.logger({
transports: [
new winston.transports.Console({
colorize: true
}),
new winston.transports.File({
name: 'access-file',
filename: 'access-error.log',
level: 'info' //This setting is what i need to change for access lines only
})
],
ignoreRoute: function(req) {
return (req.url === '/healthcheck');
},
meta: false,
msg: "HTTP {{req.method}} {{req.url}}",
colorStatus: true
}));
问题是我不知道如何仅隔离访问日志行。这可能吗?
答案 0 :(得分:0)
当然,只需配置“访问”的自定义日志记录级别,然后根据需要将其指向文件。
https://github.com/winstonjs/winston#using-custom-logging-levels