gpt4 book ai didi

xml - log4j - 为什么 logger.debug 不工作?

转载 作者:行者123 更新时间:2023-12-02 01:10:53 25 4
gpt4 key购买 nike

我的 log4j.xml 文件具有以下配置:

   <appender name="fileAppender"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="INFO" />
<!-- Change Log File Root when Environment is Set Up -->
<param name="File" value="${root}/application.log"/>
<param name="DatePattern" value=".yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MMM-dd HH:mm:ss,SSS} [%t] %c %x%n %-5p %m%n"/>
</layout>
</appender>

<logger name="db.scheduler" additivity="false" >
<level value="all"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>

但是。当我执行 logger.debug 时,它不会添加任何内容! logger.info 和 logger.error 工作...但不是 logger.debug!

最佳答案

<param name="Threshold" value="INFO" />

您的阈值设置为 INFO,即低于 DEBUG 的级别,因此任何调试消息都不会通过过滤器。参见 here对于相对水平:

Level       Description
===== ===========
OFF The highest possible rank and is intended to
turn off logging.
FATAL Severe errors that cause premature termination.
Expect these to be immediately visible on a
status console.
ERROR Other runtime errors or unexpected conditions.
Expect these to be immediately visible on a
status console.
WARN Use of deprecated APIs, poor use of API,
'almost' errors, other runtime situations that
are undesirable or unexpected, but not
necessarily "wrong". Expect these to be
immediately visible on a status console.
INFO Interesting runtime events (startup or
shutdown). Expect these to be immediately
visible on a console, so be conservative
and keep to a minimum.
DEBUG Detailed information on the flow through
the system. Expect these to be written to logs
only.
TRACE Most detailed information. Expect these to be
written to logs only. Since version 1.2.12.

关于xml - log4j - 为什么 logger.debug 不工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17460292/

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