[jboss-jira] [JBoss JIRA] (JBLOGGING-107) JBoss Logging throws NullPointerException when used with Log4j 2.0 final.
Nayden Gochev (JIRA)
issues at jboss.org
Thu Jul 17 04:18:30 EDT 2014
Nayden Gochev created JBLOGGING-107:
---------------------------------------
Summary: JBoss Logging throws NullPointerException when used with Log4j 2.0 final.
Key: JBLOGGING-107
URL: https://issues.jboss.org/browse/JBLOGGING-107
Project: JBoss Logging
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Components: jboss-logging-log4j
Affects Versions: 3.2.0.Beta1
Environment: <log4j.version>2.0</log4j.version>
<jboss.logging.version>3.2.0.Beta1</jboss.logging.version>
<hibernate.version>4.3.5.Final</hibernate.version>
Reporter: Nayden Gochev
Assignee: James Perkins
Priority: Blocker
When you enable logging of org.hibernate.SQL the log is not send to the log4j loggers/appenders.
The reason for that is a null pointer exception in:
Class:
Log4j2Logger
Method:
protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
Line:
50
{code:title=Log4j2Logger.java|borderStyle=solid}
@Override
protected void doLog(final Level level, final String loggerClassName, final Object message, final Object[] parameters, final Throwable thrown) {
final org.apache.logging.log4j.Level translatedLevel = Log4j2Logger.translate(level);
if (this.logger.isEnabled(translatedLevel)) {
try {
this.logger.log(null, loggerClassName, translatedLevel,
parameters == null || parameters.length == 0 ? this.messageFactory.newMessage(message) :
this.messageFactory.newMessage(String.valueOf(message), parameters),
thrown);
} catch (Throwable ignored) { }
}
}
{code}
This this.logger.log call is the one causing NPE which is ignored .. because of the surrounding catch.
If you change the call to something like :
{code:title=Example (params are not passed but you can pas them as well )|borderStyle=solid}
this.logger.log(translatedLevel,this.messageFactory.newMessage(String.valueOf(message), thrown)
{code}
As an example you will see its working.
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list