Externalized the location of logback.xml in Spring

2019-04-07 20:35发布

问题:

How can I customized the location of logback.xml in Spring Boot using application.properties?

I tried below but is not working.

application.properties

logging.config = /home/dev-01/Documents/logback.xml

It is working if the logback.xml is located in the resource folder, but not working if it is located outside the project.

It is also working if the I supply as environment variable like

-Dlogging.config=/home/dev-01/Documents/logback.xml

回答1:

Below construct worked for me (but I used relative path instead of absolute):

logging.config=file:/home/dev-01/Documents/logback.xml