Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logback 1.1.11 totalSizeCap not working

Tags:

logback

I have the following logback.xml configuration for my spring application. I'm using a SizeAndTimeBasedRollingPolicy, and I pretend to orginize the logs on a montlhy basis (that's the %d{yyyy-MM, aux} part.

For debuggin purposes, currently I'm generating a lot of logs, but the totalSizeCap doesn't seem to work. I have a folder for January that is almost 8GB.

¿Is this a bug or am I doing something wrong?

I saw this post Logback: SizeAndTimeBasedRollingPolicy not honoring totalSizeCap , but it says it is a bug of logback 1.1.7 and I'm using logback 1.1.11.

<property name="LOG_ARCHIVE" value="${LOG_PATH}/%d{yyyy-MM, aux}"/>

<appender name="RollingFile-Appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOG_PATH}/rollingfile.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
        <fileNamePattern>${LOG_ARCHIVE}/rollingfile-%d{yyyy-MM-dd}-%i.log.gz</fileNamePattern>
        <maxFileSize>100MB</maxFileSize>
        <maxHistory>50</maxHistory>
        <totalSizeCap>3GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
        <pattern>%d %-5level %r --- %yellow([%.40thread]) %.40logger{10}: %msg%n%throwable</pattern>
    </encoder>
</appender>

Thanks!

like image 713
franfran Avatar asked Feb 02 '18 15:02

franfran


1 Answers

There seems to be a bug for totalSizeCap ~2GB for logback versions < 1.2.0. Check LOGBACK-1231 for more details

like image 81
n0n0x Avatar answered Jan 04 '23 01:01

n0n0x



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!