You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Romain Manni-Bucau (JIRA)" <ji...@apache.org> on 2016/01/12 11:13:39 UTC

[jira] [Created] (LOG4J2-1251) JUL bridge broken

Romain Manni-Bucau created LOG4J2-1251:
------------------------------------------

             Summary: JUL bridge broken
                 Key: LOG4J2-1251
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1251
             Project: Log4j 2
          Issue Type: Bug
            Reporter: Romain Manni-Bucau


org.apache.logging.log4j.jul.ApiLogger doesnt behave the same depending where we come from (logger.info() vs logger.log() typically)

The main difference is the message factory used.

for this statement:

{code}
logger.info("{foo}");
{code}

a SimpleMessage will be emitted but for

{code}
logger.log(recordWithSameContent);
{code}

a MessageFormatMessage will be emitted making the log statement failling.

org.apache.logging.log4j.jul.ApiLogger#log(java.util.logging.LogRecord) should be reworked to handle such a case.

Here how to reproduce it:

{code}
Logger.getLogger("foo").info("{test}");
Logger.getLogger("foo").log(new LogRecord(Level.INFO, "{test}"));
{code}

The fix is as simple as testing org.apache.logging.log4j.jul.ApiLogger#log(java.util.logging.LogRecord) and if null don't call logger.getMessageFactory().newMessage(record.getMessage(), record.getParameters()) but logger.getMessageFactory().newMessage(record.getMessage())



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org