gpt4 book ai didi

logging - Logback中的记录器级别和阈值过滤器级别有什么区别?

转载 作者:行者123 更新时间:2023-12-02 18:26:21 26 4
gpt4 key购买 nike

我有一个带有 ThreshholdFilter 的附加程序,级别为 INFO:

<appender name="my_apender" class="com.my.apender.MyAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>

还有一个具有 INFO 级别的记录器:

<logger name="whatever" level="INFO">
<appender-ref ref="my_appender"/>
</logger>

两个级别之间有什么区别?

最佳答案

为记录器分配的级别是您的记录器使用的级别,而在过滤器 ch.qos.logback.classic.filter.ThresholdFilter 内分配的级别是此附加程序的级别正在记录东西,了解更多 details .

这是一个澄清问题的示例:

<!-- deny all events with a level below INFO, that is TRACE and DEBUG -->
<appender name="my_apender1" class="com.my.apender.MyAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>

<!-- deny all events with a level below DEBUG, that is TRACE-->
<appender name="my_apender2" class="com.my.apender.MyAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
</appender>

<!-- event with level DEBUG will be handled only by my_apender2, and events with higher levels than DEBUG will be handled by both appenders -->
<logger name="whatever" level="DEBUG">
<appender-ref ref="my_appender1"/>
<appender-ref ref="my_appender2"/>
</logger>

关于logging - Logback中的记录器级别和阈值过滤器级别有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41394606/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com