导入 jar 时的 Logback 问题

Logback issue when importing jar

我将第三方库导入到我的 Java/Spring 项目中(只是导入,没有使用库中的任何内容),当我 运行 应用程序时,我得到:

ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1aea858e - Missing integer token, that is %i, in FileNamePattern [jboss.server.log.dir_IS_UNDEFINED/bak-library-%d{yyyy-MM}.log.zip]
ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@1aea858e - See also http://logback.qos.ch/codes.html#sat_missing_integer_token
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:152)
    at org.springframework.boot.logging.logback.LogbackLoggingSystem.reinitialize(LogbackLoggingSystem.java:195)
    at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:65)
    at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:50)

我想知道 - 这是第三方库本身的问题,还是我可以在我的项目中添加一些配置来解决这个问题(基本上库假设客户端会提供这样的配置,所以它会抛出一个如果没有错误)?

从异常来看,我认为问题是,它无法解析这个

jboss.server.log.dir_IS_UNDEFINED

无法加载导致异常的属性。

在异常中的 link 之后找到

Missing integer token, that is %i, in FileNamePattern [...].

The %i conversion token is mandatory for size and time based archiving. In case the %i token is missing, SizeAndTimeBasedFNATP attached to RollingFileAppender will detect the omission and will not start.

当您使用 RollingFileAppender 时,您遵循上述 link size and time based archiving

将您的模式更改为如下示例应该可以解决问题。

jboss.server.log.dir_IS_UNDEFINED/bak-library-%d{yyyy-MM}.%i.log.zip