我想在 spring boot 应用程序中配置日志记录。我已经配置了logback-spring.xml。 logback-spring.xml 的示例位于 here application-dev.properties 文件的示例位于 here当我尝试运行 spring boot 应用程序时出现以下错误:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.util.PropertySetter@5b7a5baa - Failed to invoke valueOf{} method in class [ch.qos.logback.core.util.FileSize] with value [{LOG_FILE_MAX_SIZE}]
ERROR in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@2003496028 - maxFileSize property is mandatory.
如果我替换 <maxFileSize>{LOG_FILE_MAX_SIZE}</maxFileSize>
与 <maxFileSize>50MB</maxFileSize>
应用程序运行成功
最佳答案
尝试使用日志文件名中的变量。如果它(“50MB”)出现在文件名中,您就可以确定它已设置。
我在 pom.xml 中为配置文件“dev”设置的变量遇到了这个问题。我为我的测试使用了单独的配置文件“test”,因此未设置“dev”变量。
关于java - spring boot logback-spring.xml maxFileSize 不适用于 SizeAndTimeBasedRollingPolicy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54051792/