With commons loggin and Log4j, the TRACE level is replaced with DEBUG level.
2008-05-20 20:11
513 查看
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 );
}
}
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 );
}
}
相关文章推荐
- With commons loggin and Log4j, the TRACE level is replaced with DEBUG level.
- With commons logging and Log4j, miss the TRACE level
- What is the difference between user level threads and kernel level threads?
- libfdk_aac is incompatible with the gpl and --enable-nonfree is not specified.
- What is the difference between initWithCoder:, initWithNibName:, and awakeFromNib?
- Swift Call can throw, but it is not marked with 'try' and the error is not handled
- When starting a Java debug session with Team Debug enabled, you may receive the following error and
- 29.Your database instance is configured with automatic undo management and the UNDO_RETENTION
- swift编码出现Call can throw, but it is not marked with 'try' and the error is not handled错误的解决
- his bundle is invalid . new apps and app updates submitted to the app store must be built with publi
- Error: The Web Server Has Been Locked Down and Is Blocking the DEBUG Verb
- this bundle is invalid . new apps and app updates submitted to the app store must be built with publ
- The currently selected variant "arm-debug" uses split APKs, but none of the 1 split apks are compatible with the current device with density "213" and ABIs "x86".
- 提交时提示错误This Bundle is invalid.New apps and app updates submitted to the App Store must be built with
- Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get
- My interest is the rules/ways to implement, go and insist with interest!!!
- What is the difference between initWithCoder:, initWithNibName:, and awakeFromNib?
- 【NLP新闻-2013.05.15】How Google is setting the new search standard with voice and knowledge graph
- Dependency xpp3:xpp3:1.1.3.3 is ignored for debug as it may be conflicting with the internal versio
- Debug of the kernel with VMWare and kgdb