How to properly configure logback using environment variables

59 views Asked by At

I have this in my appication.properties file:

logs.home=/var/log

and on my logback-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <property name="LOGS" value="${logs.home}" />

...
</configuration>

but when I start I have this problem: logs.home_IS_UNDEFINED

1

There are 1 answers

0
Andy Wilkinson On BEST ANSWER

You need to use <springProperty>. Something like this:

<springProperty scope="context" name="LOGS" source="logs.home"/>

You can learn more in the relevant section of Spring Boot's reference documentation.