When using the Logback trigger policy SizeAndTimeBasedFNATP, how to limit the number of files per day? For example, any day I donβt want to have more than 100 MB of magazines. Given that each log (in the example below) is 20 MB, I would like to be able to set a maximum limit of 5 files per day.
FixedWindowRollingPolicy provides the maxIndex property, but TimeBasedRollingPolicy does not have maxIndex. Is there a recommended approach for using maxIndex when using TimeBasedRollingPolicy?
<appender name="some.file" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <fileNamePattern>logs/some_app_%d{yyyyMMdd}.log.%i</fileNamePattern> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <maxFileSize>20MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> </rollingPolicy> <encoder> <pattern>%level %date{yyyy-MM-dd HH:mm:ss:SSS} %msg%n</pattern> </encoder>
source share