5

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!

franfran
  • 113
  • 1
  • 9

1 Answers1

7

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

n0n0x
  • 86
  • 2