Issue
I have logback.xml
like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="2 seconds">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<jmxConfigurator/>
<logger name="org.springframework" level="INFO"/>
<logger name="org.springframework.web.filter.CommonsRequestLoggingFilter" level="DEBUG"/>
<logger name="com.mypackage" level="WARN"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<turboFilter class="ch.qos.logback.classic.turbo.DynamicThresholdFilter">
<Key>dynamicLogLevel</Key>
<DefaultThreshold>DEBUG</DefaultThreshold>
<MDCValueLevelPair>
<value>dynamicLogLevelDEBUG</value>
<level>DEBUG</level>
</MDCValueLevelPair>
<!-- dynamicLogLevelERROR for testing -->
<MDCValueLevelPair>
<value>dynamicLogLevelERROR</value>
<level>ERROR</level>
</MDCValueLevelPair>
</turboFilter>
.....
</configuration>
I want to set the logger level, appenders , rolling policy present in logback.xml
in application.yaml
.
I have gone through this Doc but did not find sufficient info.
I'm using spring-boot 1.4.4-RELEASE
.
Solution
I found the solution:
My application.yaml
in some folder(say C:/configuration/application.yaml
, c:/configuration/logback.xml
).
In logback.xml
, we can access application.yaml
contents using :
<property file="${HOME}/configuration/application.yaml"/>
for ex: in application.yaml
LOG_FILE : C:/logs
in logback.xml access it:
<appender name="MY_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_FILE}</file>
...
</appender>
But take care of value scanPeriod in
<configuration scan="true" scanPeriod="10 seconds">
Hope it will help.
Answered By - Sai prateek
Answer Checked By - Marie Seifert (JavaFixing Admin)