Logback Spring 可加性中的块日志级别
Logback Spring Block Log Level in Additivity
我使用 spring 启动应用程序,得到重复的错误级别日志,所以我添加了 additivity="false"
阻止其他两个级别。
配置如下,
<configuration>
<property resource="application.properties" />
<springProperty scope="context" name="uuid" source="uuid"/>
<springProperty scope="context" name="environment" source="label"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<appender name="ERROR" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-ERROR}</level>
</filter>
<filter class="com.sample.ErrorFilter">
<criticalUUID>${uuid}</criticalUUID>
<criticalEnvironment>${environment}</criticalEnvironment>
</filter>
</appender>
<appender name="WARN" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-WARN}</level>
</filter>
<filter class="com.sample.WarningFilter">
<warningUUID>${uuid}</warningUUID>
<warningEnvironment>${environment}</warningEnvironment>
</filter>
</appender>
<root level="DEBUG">
<appender-ref ref="ERROR"/>
<appender-ref ref="WARN"/>
<appender-ref ref="STDOUT"/>
</root>
<logger name="com.refinitiv" level="ERROR" additivity="false">
<appender-ref ref="ERROR" />
</logger>
</configuration>
有什么建议吗?
有什么建议吗?我尝试在 application.properties
中使用
我解决了问题,日志层次结构导致了问题。
<appender name="ERROR" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-WARN}</level>
</filter>
<filter class="com.sample.ErrorFilter">
<criticalUUID>${uuid}</criticalUUID>
<criticalEnvironment>${environment}</criticalEnvironment>
</filter>
</appender>
并删除了 <appender name="WARN"
由于WARN级别在hierarchy中调用ERROR,参考如下url.
log4j logging hierarchy order
我使用 spring 启动应用程序,得到重复的错误级别日志,所以我添加了 additivity="false"
阻止其他两个级别。
配置如下,
<configuration>
<property resource="application.properties" />
<springProperty scope="context" name="uuid" source="uuid"/>
<springProperty scope="context" name="environment" source="label"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<appender name="ERROR" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-ERROR}</level>
</filter>
<filter class="com.sample.ErrorFilter">
<criticalUUID>${uuid}</criticalUUID>
<criticalEnvironment>${environment}</criticalEnvironment>
</filter>
</appender>
<appender name="WARN" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-WARN}</level>
</filter>
<filter class="com.sample.WarningFilter">
<warningUUID>${uuid}</warningUUID>
<warningEnvironment>${environment}</warningEnvironment>
</filter>
</appender>
<root level="DEBUG">
<appender-ref ref="ERROR"/>
<appender-ref ref="WARN"/>
<appender-ref ref="STDOUT"/>
</root>
<logger name="com.refinitiv" level="ERROR" additivity="false">
<appender-ref ref="ERROR" />
</logger>
</configuration>
有什么建议吗?
有什么建议吗?我尝试在 application.properties
中使用我解决了问题,日志层次结构导致了问题。
<appender name="ERROR" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logging.console.level:-WARN}</level>
</filter>
<filter class="com.sample.ErrorFilter">
<criticalUUID>${uuid}</criticalUUID>
<criticalEnvironment>${environment}</criticalEnvironment>
</filter>
</appender>
并删除了 <appender name="WARN"
由于WARN级别在hierarchy中调用ERROR,参考如下url.
log4j logging hierarchy order