I'm trying to manage my logging in a way in which my oldest archived logfiles are deleted once they've either reached the total cumulative size limit or reached their maximum history limit. When using the SizeAndTimeBasedRollingPolicy
in Logback 1.1.7, the rolling file appender will keep creating new archives in spite of exceeding the totalSizeCap
set.
Here's my logback.xml file for reference:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="file"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${USERPROFILE}/testlogs/test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>
${USERPROFILE}/testlogs/%d{yyyy-MM-dd_HH}/test%i.log.zip
</fileNamePattern>
<maxHistory>7</maxHistory>
<maxFileSize>50KB</maxFileSize>
<totalSizeCap>200KB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %5p - %m%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="file" />
</root>
</configuration>
Is this a bug in logback or am I not configuring the rolling file appender correctly?