I have packaged my Spring-boot application with the spring-boot-maven-plugin. I use one library, which searches for some files on the classpath. Therefore I need to add additional resources directories on the classpath. I am using following command to run the application:
java -cp "C:\temp\some-dir;C:\temp\another-dir;my-application-1.0.jar" org.springframework.boot.loader.JarLauncher
The application starts and runs successfully, however the log4j2 configuration is not used. When I check the archive, the log4j2.xml is copied into the BOOT-INF/classes, which is the last entry in the classloader. I guess, that is why the log4j2 is not configured correctly.
But when I run the application through java -jar
, omitting the additional classpath, the log4j2 configuration is successfully set up.
My only workaround so far is to specify the logging configuration externally as -Dlogging.config=classpath:log4j2.xml
, but I would like to have everything encapsulated.
Any ideas how to make this work?