Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-Dlogback.configurationFile=logback.xml ignored when running Spring-Boot

The default strategy assumes that if you don't have a logback.xml (or one of the other standard file names) in the classpath then you must be happy with the defaults (see LogbackLoggingSystem for details). Spring Boot tries to unify the external configuration switches for common logging sytems, so it looks in logging.config (it didn't know about logback.configurationFile). You could use that instead (i.e. logging.config=file:./src/test/resources/logback.xml), or make sure your config file is on the classpath.


I know this post is a bit old but adding the following to application.properties is a quick workaround based on Dave Syer's answer:

logging.config=${logback.configurationFile}

According to Spring Boot documentation, you could run like this:

java -jar app.jar --logging.config=./src/test/resources/logback.xml

Additionally, Spring Boot tries to unify the properties name of the different log startegies. As a result, the JVM parameter Dlogback.configurationFile is not used for Spring Boot.


If logback xml is under resources folder, you can add following to VM option:

java -jar App.jar -Dlogging.config=classpath:logback-local.xml