Skip to main content

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender and suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicySizeBasedTriggeringPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender and suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender and suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedTriggeringPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

added 4 characters in body
Source Link
Jonathan Williams
  • 14.5k
  • 1
  • 26
  • 59

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender and suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender and suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

deleted 339 characters in body
Source Link
Jonathan Williams
  • 14.5k
  • 1
  • 26
  • 59

Looking at the Logback demo page the following works for the 'CyclicBufferAppender':

<appender name="CYCLIC" class="ch.qos.logback.core.read.CyclicBufferAppender">
  <MaxSize>512</MaxSize>
</appender>

I have not tried it, but this may also be the same syntax for the RollingFileAppender.


[UPDATE BELOW][UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

Looking at the Logback demo page the following works for the 'CyclicBufferAppender':

<appender name="CYCLIC" class="ch.qos.logback.core.read.CyclicBufferAppender">
  <MaxSize>512</MaxSize>
</appender>

I have not tried it, but this may also be the same syntax for the RollingFileAppender.


[UPDATE BELOW]

The following XML is also given on the logback site. This uses the RollingFileAppender suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

[UPDATED]

The following XML is also given on the logback site. This uses the RollingFileAppender suggests that the 'maxFileSize' element needs to be inside a 'triggeringPolicy':

<configuration>
  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>test.log</file>

    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
      <fileNamePattern>tests.%i.log.zip</fileNamePattern>
      <minIndex>1</minIndex>
      <maxIndex>3</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
      <maxFileSize>5MB</maxFileSize>
    </triggeringPolicy>
    <encoder>
      <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
    </encoder>
  </appender>
        
  <root level="DEBUG">
    <appender-ref ref="FILE" />
  </root>
</configuration>

The following information is also given on the site too:

Specified number is not in proper int form, or not expected format.

When you specify the MaxFileSize to be used by the SizeBasedRollingPolicy, logback expects a rather precise format:

The number has to be an integer You can add 'KB', 'MB' or 'GB' after the number. Here are some correct values: 500KB, 15MB, 2GB.

Added a more specific code example for the scenario
Source Link
Jonathan Williams
  • 14.5k
  • 1
  • 26
  • 59
Loading
Source Link
Jonathan Williams
  • 14.5k
  • 1
  • 26
  • 59
Loading