[
https://issues.apache.org/jira/browse/LOG4J2-1251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Romain Manni-Bucau updated LOG4J2-1251:
---------------------------------------
Attachment: LOG4J2-1251___2.patch
not using git diff but git diff origin/master to create the patch
> JUL bridge broken
> -----------------
>
> Key: LOG4J2-1251
> URL: https://issues.apache.org/jira/browse/LOG4J2-1251
> Project: Log4j 2
> Issue Type: Bug
> Components: JUL adapter
> Reporter: Romain Manni-Bucau
> Attachments: LOG4J2-1251.patch, LOG4J2-1251___2.patch
>
>
> 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: [email protected]
For additional commands, e-mail: [email protected]