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 );
}
}
分享到:
相关推荐
官网下载,未作任何改动
为什么同时使用commons-logging和Log4j?commons-logging为我们提供了统一的日志接口,可以用各种日志工具类。log4j是目前输出日志的首选。
NULL 博文链接:https://qq405371160.iteye.com/blog/1769468
NULL 博文链接:https://icourses.iteye.com/blog/1839984
log4j-1.2.14.jar log4j-core-2.1.jar log4j-api-2.1.jar commons-logging-1.2.jar commons-logging-1.1.1.jar commons-logging-1.0.4.jar
log4j 用的两个jar包,log4j-1.2.14.jar 和 commons-logging-1.1.jar
log4j日志包 log4j.jar\commons-logging-1.1.1.jar private static final Log log = LogFactory.getLog(xxxxxx.class); 下载后解压就能得到这两个包
log4j.properties ,commons-logging-1.2.jar,log4j-1.2.16.jar,三个文件一起组成一个完整的日志输出,Apache的Common Logging只是一个高层的日志框架,本身并没有实现真正的写日志能力,而是依赖其它的日志系统如...
这是一个讲解commons-logging 和log4j的使用方法,里面有一些例子供大家参考。
日志框架需要的Jar包 commons-logging.jar log4j.jar
配置日志文件时需要的jar包,配置日志文件时需要的jar包,配置日志文件时需要的jar包
NULL 博文链接:https://tianjun309.iteye.com/blog/776137
最新上传的经典的log4j使用文档 Log4j和commons-log4j不是同一个记日志的工具 ①配置根Logger ②配置日志信息输出目的地Appender ③配置日志信息的格式(布局)
NULL 博文链接:https://zy19982004.iteye.com/blog/1867448
我发现几乎所有的Java开源项目都会用到Log4j,但我同时发现,所有用到Log4j的项目一般也同时会用到commons-loggin。我想,大家都不希望自己的项目与Log4j绑定的太紧密吧。另外一个我能想到的“同时使用commons-...
文档中介绍 log4j2 的怎么配置和使用
hibernate3.3.2+commons-lang2.3+slf4j1.5.8+log4j1.2.16数据库的驱动请直接去自己的数据库的安装包中找到即可
NULL 博文链接:https://cnetwei.iteye.com/blog/266074
《log4j-1.2.12.jar commons-logging.jar java项目 定时调度 自定义日志》 log4j算是比较好用的日志操作插件了吧,一般与commons-logging一起使用,一直没时间去搞,现在空出了点儿时间,写了一个定时调度程序,将...
java spring学习所需要的jar配置文件和commons配置文件