Hi,
We were using logback’s ‘ConsoleAppender’ for couple of our projects which was working good.
Recently we are trying to use the ‘RollingFileAppender’ with ‘timeBasedFileNamingAndTriggeringPolicy’ and class "ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP" and facing issues with the deleting of the older archived files.
Issue is that it doesn’t always delete files older than the max history period when there is considerable time gap between the logging events.
I can see many people raising this issue but couldn’t find any information that this is resolved in any particular release. We are using the 0.9.17 and 0.9.24 versions and this problem occurs in both the versions.
Below are the appender configurations of both the projects with the logback release versions used.
Project 1: -------------------------------------------------
Uses logback-core 0.9.17
<appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/tmp/GcrDBS/test/dbs.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/var/tmp/GcrDBS/test/dbs.log.%d{yyyy-MM-dd_HH-mm}.%i.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>500KB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>6</maxHistory>
</rollingPolicy>
<layout name="stdLayout" class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{MMM dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
Project 2: -------------------------------------------------
Uses logback-core 0.9.24
<appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/tmp/GcrWFC/test/dbs.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/var/tmp/GcrWFC/test/dbs.log.%d{yyyy-MM-dd_HH-mm}.%i.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100KB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>5</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{MMM dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
Could someone please let me know if this is fixed in any release? And if so what is that? Or any work around for this?
Thanks in advance.
Kalyan