Ryan Rupp created LOG4J2-924:
--------------------------------
Summary: Log4j 1.2 Bridge doesn't translate trace level ALL
correctly in Category.getEffectiveLevel()
Key: LOG4J2-924
URL: https://issues.apache.org/jira/browse/LOG4J2-924
Project: Log4j 2
Issue Type: Bug
Reporter: Ryan Rupp
Priority: Minor
If I have in my logger configs:
{code}
<logger name="org.hibernate" level="ALL"/>
{code}
Using "ALL" as my log level for hibernate. Hibernate uses jboss-logging.
Jboss-logging just recently added support for Log4j2 (see version 3.2 -
https://issues.jboss.org/browse/JBLOGGING-95). However, I'm using 3.1.4
currently which ends up then using the log4j 1.2 bridge so:
jboss-logging 3.1.4--->log4j 1.2 bridge--->log4j2
I noticed some Hibernate code failing checking the logger level such as:
{code}
if (logger.isTraceEnabled() {
// log something expensive
}
{code}
Looking into this, it checks the loggers effective level against the passed in
level. So in this case the loggers effective level should be ALL which should
include TRACE. However, in the log4 1.2 bridge Category.getEffectiveLevel()
doesn't have a case statement for ALL so it ends up defaulting to OFF:
{code}
public final Level getEffectiveLevel() {
switch (logger.getLevel().getStandardLevel()) {
case TRACE:
return Level.TRACE;
case DEBUG:
return Level.DEBUG;
case INFO:
return Level.INFO;
case WARN:
return Level.WARN;
case ERROR:
return Level.ERROR;
case FATAL:
return Level.FATAL;
default:
return Level.OFF;
}
}
{code}
Here's the JBoss logging check for reference -
https://github.com/jboss-logging/jboss-logging/blob/master/src/main/java/org/jboss/logging/Log4jLogger.java#L36
The first conditional will be true but the second will be false due to the
issue of mapping the ALL level.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]