Is it possible to only write the access lines from express to a log file, and keep the other logs in the console? Something like this:
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
}));
The problem is that I do not know how to isolate just the access log lines. Is this possible?
Sure, just configure a custom logging level of 'access' and then point it at the file as you like.
https://github.com/winstonjs/winston#using-custom-logging-levels