log4js-example
log4js-example copied to clipboard
app.log is also including access logs
I am having the same problem. Any idea how to change the configuration so this won't happen ?
Basically you can have two appenders, one for application logs and another one for access logs. Then just exclude application from access logs (category 'http'):
{
"type": "dateFile",
"filename": config.server.logs.accessLogs.filename,
"pattern": "-yyyy-MM-dd",
"layout": {"type": "messagePassThrough"},
"category": "http"
},
{
"type": "categoryFilter",
"exclude": ["http"],
"appender": {
"type": "dateFile",
"filename": config.server.logs.applicationLogs.filename,
"pattern": "-yyyy-MM-dd",
"layout": {
"type": "pattern",
"pattern": commonPattern,
"tokens": commonPatternTokens
}
}
}
Then you need to set an specific connector for those access logs:
app.use(log4js.connectLogger(log4js.getLogger('http'), { level: 'auto', format: config.server.logs.accessLogs.pattern }))