I have the following configuration of my logger in a Node.js script:
const log4js = require('log4js');
log4js.configure({
appenders: {
out: {
type: "dateFile",
filename: conf.logsFolder "etl-processing.log",
pattern: "yyyy-MM-dd-hh-mm-ss",
alwaysIncludePattern:true,
keepFileExt:true
}
},
categories: {
default: { appenders: ['out'], level: 'debug' }
}
});
const logger = log4js.getLogger();
logger.info ("yada yada yada...")
logger.error ("yada yada yada...")
Why does log4js produce two log files: one empty and one with all logs? Am I missing something?
The result is always sth like this (2 files separated in time with 1 sec):
- etl-processing.2022-10-04-13-40-29.log
- etl-processing.2022-10-04-13-40-30.log
CodePudding user response:
The pattern
argument refers to the date pattern added to the file name. With the configuration you provided, it will roll over every second. You could change the pattern
to something a bit more lax, or even omit it entirely and let it default to yyyy-MM-dd
.