Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1489

with SizeAndTimeBasedRollingPolicy totalSizeCap cannot be smaller than maxFileSize

    XMLWordPrintable

    Details

      Description

      trying to setup SizeAndTimeBasedRollingPolicy with totalSizeCap smaller than maxFileSize, i get this error:

       

      11:43:00,082 |-ERROR in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@43834411 - totalSizeCap of [2 MB] is smaller than maxFileSize [5 MB] which is non-sensical

       

       

      it is true that for plaintext files a smaller totalSizeCap would be non-sensical, but it may make perfect sense if log files are zipped/gzipped.

      Logs compress very well. If applying gzip, a 100MB log file is compressed to a file that is usually 10MB to 1MB (or less). In this case it is reasonable to have, as an example, maxFileSize set to 100M and totalSizeCap set to 50MB.

       

      Config example:

      <appender name="MYAPPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
       <file>${LOG_DIR}/${LOG_NAME}.log</file>
       <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
       <fileNamePattern>${LOG_ARCHIVE_DIR}/${LOG_NAME}.log.%d{yyyy-MM-dd}.%i.gz</fileNamePattern>
       <maxFileSize>100MB</maxFileSize> 
       <maxHistory>10</maxHistory>
       <totalSizeCap>50MB</totalSizeCap>
       </rollingPolicy>
       <encoder>
       <pattern>${LOG_PATTERN}</pattern>
       </encoder>
       </appender>

        Attachments

          Activity

            People

            Assignee:
            logback-dev Logback dev list
            Reporter:
            davide.imbriaco Davide Imbriaco
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: