Details
-
Bug
-
Resolution: Unresolved
-
Critical
-
None
-
1.2.3
-
None
-
Description
SizeAndTimeBasedRollingPolicy does not zip all the files on day change. Due to that it does not clean/delete the older (older than MaxHistory) files.
We've the application those are generating big (2GB/3GB) log files on daily basis, so that's why we moved to SizeAndTimeBasedRollingPolicy from TimeBasedRollingPolicy, but here is a problem that (SizeAndTimeBasedRollingPolicy) does not zip/archive all the files on day change, that's why when max history reached, those files which were archived/zipped were deleted but rest were left there as stale.
I googled but did not find any solution for that.
Please consider adding this feature to Logback and feel free to contact me if further clarification is required. I think logback should change the algo to delete the directories those are older than maxHistory limit not concentrating on the individual files.
This is our logback appender.
<property name="dirName" value="%d{${datePattern:-yyyy-MM-dd}}" scope="context"/> <appender name="OVERALL" class="ch.qos.logback.core.rolling.RollingFileAppender"> <append>true</append> <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> <!-- Daily rollover --> <fileNamePattern>${dirName}/logFile_overall.%i.log.zip</fileNamePattern> <maxFileSize>100MB</maxFileSize> <!-- History in days --> <maxHistory>1</maxHistory> <!--<totalSizeCap>0kB</totalSizeCap>-> </rollingPolicy> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss} | %-5p | [%thread] %logger{5}:%L - %msg%n</pattern> </encoder> </appender>
Please find the example project attached.