Skip to content

dateFile Appender daysToKeep not rolling by days #1035

@wangduanduan

Description

@wangduanduan

daysToKeep - integer (default 0) - if this value is greater than zero, then files older than that many days will be deleted during log rolling.

when the pattern is not .yyyy-MM-dd, the daysToKeep not work as doc says.

for example. when pattern is .yyyy-MM-dd-hh-mm, the daysToKeep is not control the old log Rolling by days, just keep the logs backups not more than daysToKeep.

log4js.configure({ appenders: { well: { type: 'dateFile', filename: logFileName, pattern: '.yyyy-MM-dd-hh-mm', compress: true, daysToKeep: 3 }, console: { type: 'console' } }, categories: { well: { appenders: [ 'well' ], level: 'debug'}, default: {appenders: ['console'], level: 'debug'} } }) 

log files

-rw-r--r-- 1 dd staff 855B Aug 1 14:59 well.log -rw-r--r-- 1 dd staff 197B Aug 1 14:39 well.log.2020-08-01-14-38.gz -rw-r--r-- 1 dd staff 323B Aug 1 14:45 well.log.2020-08-01-14-39.gz -rw-r--r-- 1 dd staff 140B Aug 1 14:59 well.log.2020-08-01-14-45.gz 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions