Reputation: 25
I want to call local location value(c:/temp) from application.properties file in logback.xml file.
currently i am specify location value in logback.xml itself, it's working fine.
logback.xml
<configuration>
<property name="LOG_PATTERN" value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %p %m%n" />
<property name="APP_LOG_ROOT" value="c:/temp"/>
...
</configuration>
But i want to call value from application.properties file.
application.properties
''' log.location.value = c:/temp '''
what i have to change in logback.xml file.
Thank you.
Upvotes: 0
Views: 1324
Reputation: 31
If you have configured my logback-spring.xml as per Spring Boot Documentation, this might be a better solution. Instead of calling the whole application.properties in your logback.xml file, you can refer to a specific property in the application.properties file like this:
<springProperty scope="context" name="APP_TIMEZONE" source="application.timezone" />
Then you can use the springProperty like this: ${APP_TIMEZONE}. This way you can call a specific value in the application.properties file.
<Pattern>
%d{ISO8601,${APP_TIMEZONE}} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
Upvotes: 0
Reputation: 2694
Include the below snippet in your logback.xml :
<property resource="application.properties" />
This will let you refer properties in a standard way
Example : ${app.name}.
Upvotes: 1