Tag Archives: logback

[Solved] logback ERROR SizeAndTimeBasedFNATP & DefaultTimeBasedFileNamingAndTriggeringPolicy

1. Description

Project started, Logback configuration error (FileNamePattern format and timeBasedFileNamingAndTriggeringPolicy did not correspond to it).

environment

IDE: 2021.3
spring boot: 2.5.6 (spring-boot-starter-logging: 2.5.6 --- logback-classic: 1.2.6)

Configuration 1:

	<FileNamePattern>${LOG_HOME}/info${LOG_NAME}_%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy" />

Configuration 2:

	<FileNamePattern>${LOG_HOME}/info${LOG_NAME}_%d{yyyy-MM-dd}.log</FileNamePattern>
    <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
        <maxFileSize>10KB</maxFileSize>
    </timeBasedFileNamingAndTriggeringPolicy>

2. Problems

Question 1:

Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Filename pattern [/var/demo_log_logback_%d{yyyy-MM-dd}.part_%i.log] contains an integer token converter, i.e. %i, INCOMPATIBLE with this configuration. Remove it.
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)

Question 2:

Logging system failed to initialize using configuration from 'null'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@56cdfb3b - Missing integer token, that is %i, in FileNamePattern [/var/demo_log_logback_%d{yyyy-MM-dd}.log]
ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@56cdfb3b - See also http://logback.qos.ch/codes.html#sat_missing_integer_token
	at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)

reason:

DefaultTimeBasedFileNamingAndTriggeringPolicy: Do not Support %i
SizeAndTimeBasedFNATP: Need %i

3. Solution

Adjust the parameter value format of FileNamePattern.

4. Information

Logback manual appender label: https://logback.qos.ch/manual/appenders.html