How to limit the number of files per day when using Logback SizeAndTimeBasedFNATP

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> 

+4
source share
1 answer

this is currently not possible. Look at this Logback answer , set the maximum history files per day . You cannot overturn a calendar / start policy based on time and size.

+2
source

Source: https://habr.com/ru/post/1394248/


All Articles