Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback SizeBasedTriggeringPolicy is not rolling

I have this configurarion:

<appender name="ROLLIN" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${SCRIPTMON_HOME}/logs/scriptMon.log</file>
    <encoder>
        <pattern>%d{yyyy-MMM-dd HH:mm:ss.SSS} %-5level [%thread] %logger{15} - %msg%n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${SCRIPTMON_HOME}/logs/scriptMon.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>10</maxIndex>
    </rollingPolicy>
    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
</appender>

IFAIK my logfile must rotate when it reaches 5MB (this is all I want regardless the date). I can in one run in Springboot achieve more than 10MB and the files stays the same.

I would appreciate any help.

Thanks.

like image 781
Marcelo Ribeiro Avatar asked Sep 10 '26 02:09

Marcelo Ribeiro


1 Answers

Try changing

<fileNamePattern>${SCRIPTMON_HOME}/logs/scriptMon.%d{yyyy-MM-dd}.%i.log.zip</fileNamePattern>

to

<fileNamePattern>${SCRIPTMON_HOME}/logs/scriptMon.%i.log.zip</fileNamePattern>
like image 80
Kael Avatar answered Sep 12 '26 17:09

Kael