Log4j XML配置调试级别问题 [英] Log4j XML configuration debug level issue

查看:601
本文介绍了Log4j XML配置调试级别问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的项目使用log4j xml配置,而不是log4j.properties文件.我正在尝试在Eclipse控制台中显示调试消息.但这没有解决.而是显示了信息消息.

I am using log4j xml configuration for my project, NOT log4j.properties file. I am trying to display debug messages in eclipse console. But it didn't worked out. Instead, info messages are being displayed.

下面是我的log4j xml配置文件

Below is my log4j xml configuration file

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
  <appender name="console" class="org.apache.log4j.ConsoleAppender"> 
    <param name="Target" value="System.out"/> 
    <param name="Threshold" value="debug" />
    <layout class="org.apache.log4j.PatternLayout"> 
      <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/> 
    </layout> 
  </appender> 

  <root> 
    <level value ="debug" /> 
    <appender-ref ref="console" /> 
  </root>

</log4j:configuration>

在我的代码中,我正在检查以此方式设置的日志级别

In my code I am checking what log level is set this way

if(LOG.isDebugEnabled()){
            LOG.debug("debug is enabled");
            LOG.info("Debug enabled but using info to display this message");
            System.out.println("sys out debug is enabled");
}

我的eclipse控制台日志输出如下:

My eclipse console log output is hereunder:

12:08:51,191 INFO  [com.abc.servlets.MainServlet] (http-localhost-127.0.0.1-8080-2) Debug enabled but using info to display this message
12:08:51,192 INFO  [stdout] (http-localhost-127.0.0.1-8080-2) sys out debug is enabled

其他信息:我正在使用Jboss App服务器.

Additional Information : I am using Jboss App server.

仍然在努力,对我来说错在哪里并没有给我留下深刻印象.

Still working on this, it didn't strike for me where I was wrong.

推荐答案

应该

<priority value ="debug" />

代替

<level value ="debug" /> 

 <root> 
    <level value ="debug" /> 
    <appender-ref ref="console" /> 
  </root>

这篇关于Log4j XML配置调试级别问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆