Here's how I got it to work:
The problem is that the default category for the appender configuration is "[all]". Set the category to [[default] , and it only applies to registrars who βreceivedβ without a category: log4js.getLogger()
{ appenders: [ { type: 'console', category: '[default]' }, { type: 'file', filename: 'logs/cheese.log', category: 'cheese' } ] }
More explanation:
You probably have / have something similar to the appender config example
{ appenders: [ { type: 'console' }, { type: 'file', filename: 'logs/cheese.log', category: 'cheese' } ] }
And then you get a registrar with or without a category name:
var logger = log4js.getLogger(); var cheeseLogger = log4js.getLogger('cheese'); logger.info(1) cheeseLogger(2)
Exit:
[2016-10-25 15:43:06.225] [INFO] [default] - 1 [2016-10-25 15:43:06.225] [INFO] cheese - 2
logs / cheese.log:
[2016-10-25 15:43:06.225] [INFO] cheese - 2
source share