Spring boot does not load logback-spring.xml
Dockerfile:
COPY /rootProjectName/src/main/resources/logback-spring.xml /deployments/
application-dev.properties:
logging.config=classpath:logback-spring.xml
I'm running a docker container and must copy over the resource folder into my deployments folder in my Docker File... but once copied over
this is the logging.config value that works for me (adding the classpath word)
As per the description of the problem, you are using the externalized version of your log configuration. The file is kept outside the jar. So you have to mention the path as run-time argument as below:
-Dlogging.config=file:logback-spring.xml
Or in mention the same property in application.properties as below:
logging.config=file:logback-spring.xml
The reason it pickup the file from resources folder, because it is configured in spring that way. Spring pick up the logback file by below names from classpath.
logback-spring.xml, logback-spring.groovy, logback.xml, or logback.groovy
Please check the relevant docs at spring-boot custom log configuration
Just define these lines in your logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework.web" level="DEBUG"/>
</configuration>
By default, Spring will not look for resources outside the jar file. If you want to use an external logback configuration file, you must pass it's location when starting the jar:
$ java -jar -Dlogback.configurationFile=/full_path/logback.xml app.jar
Please, do not include the logback.xml into the final Jar file, it will cause multiple logback.xml files in the classpath.