logback ERROR SizeAndTimeBasedFNATP & DefaultTimeBasedFileNamingAndTriggeringPolicy
1. 描述项目启动,Logback配置出错(FileNamePattern格式和timeBasedFileNamingAndTriggeringPolicy没对应上)。环境IDE: 2021.3spring boot: 2.5.6 (spring-boot-starter-logging: 2.5.6 --- logback-classic: 1.2.6)配置1:<FileNamePatte
·
1. 描述
项目启动,Logback配置出错(FileNamePattern格式和timeBasedFileNamingAndTriggeringPolicy没对应上)。
- 环境
IDE: 2021.3
spring boot: 2.5.6 (spring-boot-starter-logging: 2.5.6 --- logback-classic: 1.2.6)
- 配置1:
<FileNamePattern>${LOG_HOME}/info${LOG_NAME}_%d{yyyy-MM-dd}.part_%i.log</FileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy" />
- 配置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. 问题
- 问题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)
- 问题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)
- 原因:
DefaultTimeBasedFileNamingAndTriggeringPolicy : 不支持 %i
SizeAndTimeBasedFNATP: 需要 %i
3. 解决
- 调整 FileNamePattern的参数值格式。
4. 资料
logback 手册appender标签:https://logback.qos.ch/manual/appenders.html
更多推荐
已为社区贡献1条内容
所有评论(0)