With commons loggin and Log4j, the TRACE level is replaced with DEBUG level.

Recently, when I was using the commons logging 1.0.4 and log4j 1.2.13, I found the log level TRACE is replaced with DEBUG. Then I trace into the codes, I found the Apache commons logging has the TRACE level earlier than log4j. So when it process the trace level, it will send the TRACE message to log4j with DEBUG level. Please update to the latest packages for both commons loggin and log4j. Please see the relative codes.

Please see the codes in Log4JLogger.java in version commons loggin 1.0.4

    public void trace(Object message) {
        if(is12) {
            getLogger().log(FQCN, (Priority) Level.DEBUG, message, null );
        } else {
            getLogger().log(FQCN, Level.DEBUG, message, null );
        }
    }

Please see the codes in Log4JLogger.java in version commons loggin 1.1

    static {
        if (!Priority.class.isAssignableFrom(Level.class)) {
            // nope, this is log4j 1.3, so force an ExceptionInInitializerError
            throw new InstantiationError("Log4J 1.2 not available");
        }
       
        // Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier
        // versions do not. If TRACE is not available, then we have to map
        // calls to Log.trace(...) onto the DEBUG level.
       
        try {
            traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null);
        } catch(Exception ex) {
            // ok, trace not available
            traceLevel = Priority.DEBUG;
        }
    }


    public void trace(Object message, Throwable t) {
        if(is12) {
            getLogger().log(FQCN, (Priority) Level.DEBUG, message, t );
        } else {
            getLogger().log(FQCN, Level.DEBUG, message, t );
        }
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值