Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extern log4.properties file with Spring Boot

I am running my app with executable jar.

I have log4j.properties inside /resources folder

In prod I would like to override it and have it within external dir

How I could do that using Spring-Boot?

like image 805
rayman Avatar asked Jan 21 '15 16:01

rayman


2 Answers

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

http://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html

like image 161
Johan Frick Avatar answered Nov 01 '22 11:11

Johan Frick


If you don't like to add command line arguments, you can make additional application.properties on the directory where you start the application. like:

# log4j configuration for product
logging.config=log4j-prod.properties

Then, this application.properties will override the /resources/application.properties and, the log4j-prod.properties will be used on the product environment. Please read more details on:

http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files

like image 11
Whiteship Avatar answered Nov 01 '22 12:11

Whiteship