'spring boot logback-spring.xml maxFileSize not working with SizeAndTimeBasedRollingPolicy
I want to configure logging in spring boot application. I have configure logback-spring.xml. The sample of logback-spring.xml is located on here and sample of application-dev.properties file is located here When I just try to run spring boot application get below error:
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.
If I replace <maxFileSize>{LOG_FILE_MAX_SIZE}</maxFileSize>
with <maxFileSize>50MB</maxFileSize>
application is running successfuuly
Solution 1:[1]
Try using the variable in your log filename. If it ("50MB") shows up in the filename, you know for sure that it is set.
I ran into this problem with the variables set in my pom.xml for profile "dev". I was using a separate profile "test" for my tests so the "dev" variables were not being set.
Solution 2:[2]
this will solve the issue. In logback.xml use $ with {attribute} ex:- ${max.log.size}
make sure u have initialized max.log.size with values in application.properties.
It works!!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Curtis Yallop |
Solution 2 | Sagar |