spring-boot - External log4j configuration not working

3k Views Asked by At

I am trying to do a setup for production environment, so I wanted to keep log4j.properties out of my application jar file.

For that I have kept my application.properties and log4j.properties files parallel to my spring-boot jar file. And I have given logging.config: file:log4j.properties in my application.properties. This doesn't seem to work. Spring is still picking up the log4j.properties file which is placed inside the jar file.

I have tried giving the absolute path in logging.config property like C:\Users\furquan\project\jars\log4j.properties, but it still the log4j.properties that was being used was the one inside the jar file.

Please help, its important !!!

1

There are 1 best solutions below

5
On
-Dlogging.config=/path/to/log4j.properties

Or you can specify it in your application.properties or bootstrap.properties.

From 26.5 Custom log configuration

And just a note:

After spring boot 1.4, Log4j 1 support has been removed. So maybe you can consider use the default logback, or use log4j2 instead.