我有这样的logback.xml
:
<?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>
我想设置 application.yaml
中 logback.xml
中存在的记录器级别、appenders 和滚动策略。
我经历过这个Doc但没有找到足够的信息。
我正在使用spring-boot 1.4.4-RELEASE
。
最佳答案
springProperty
标签可能就是您所需要的。 Spring Boot 将自动过滤配置文件中的 source
属性,并将占位符替换为属性中的相应值。
<configuration scan="true" scanPeriod="2 seconds">
<springProperty name="yourVar" source="key.of.your.yaml.property"/>
...${yourVar}...
关于spring - 如何在 application.yaml 中设置 logback.xml 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42648195/