Closed pikadun closed 2 years ago
From the code, if the pattern
starts with .
, the .
is removed.
https://github.com/log4js-node/streamroller/blob/e9ba0d85155ba0e8561f219faf084d521708885e/lib/DateRollingFileStream.js#L19-L21
Subsequently, FILENAME_SEP
(or .
) is added to the front of the resultant pattern
.
https://github.com/log4js-node/streamroller/blob/e9ba0d85155ba0e8561f219faf084d521708885e/lib/fileNameFormatter.js#L17-L22
I believe this is the issue.
const log4js = require('log4js');
log4js.configure({
appenders: {
test1: {
type: 'dateFile',
filename: 'test1.log',
pattern: '.yyyy-MM-dd',
alwaysIncludePattern: true,
keepFileExt: true
},
test2: {
type: 'dateFile',
filename: 'test2.log',
pattern: '-yyyy-MM-dd',
alwaysIncludePattern: true,
keepFileExt: true
},
test3: {
type: 'dateFile',
filename: 'test3.log',
pattern: '.-yyyy-MM-dd',
alwaysIncludePattern: true,
keepFileExt: true
},
},
categories: {
default: { appenders: [ 'test1', 'test2', 'test3' ], level: 'debug' }
}
});
Pattern | Expected | Actual | Test |
---|---|---|---|
.yyyy-MM-dd |
test1.2022-01-07.log |
test1.2022-01-07.log |
✔️ |
-yyyy-MM-dd |
test2-2022-01-07.log |
test2.-2022-01-07.log |
❌ |
.-yyyy-MM-dd |
test3.-2022-01-07.log |
test3.-2022-01-07.log |
✔️ |
I tried the following and it now works.
For more details: https://github.com/log4js-node/streamroller/pull/75#issue-1100547736
https://github.com/log4js-node/streamroller/blob/e9ba0d85155ba0e8561f219faf084d521708885e/lib/fileNameFormatter.js#L3
I have a dateFile appender like this
it should create a file which name like
log/info/info-yyyy-MM-dd.log
but notlog/info/info.-yyyy-MM-dd.log