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 "Ralph Goers (JIRA)" <ji...@apache.org> on 2015/10/12 22:48:05 UTC
[jira] [Comment Edited] (LOG4J2-1158) Log4J JUL adapter is using
MessageFormat on String passed by Supplier
[ https://issues.apache.org/jira/browse/LOG4J2-1158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14953695#comment-14953695 ]
Ralph Goers edited comment on LOG4J2-1158 at 10/12/15 8:47 PM:
---------------------------------------------------------------
I know we discussed the issues with our JUL compatibility with Java 8 and you expressed your reservations about using reflection for that, but I am not sure how that relates to this particular issue. Here the user wants to pass a string with "\{NULL}" in it but it fails because we are assuming it is a MessageFormatMessage instead of just a StringMessage.
was (Author: ralph.goers@dslextreme.com):
I know we discussed the issues with our JUL compatibility with Java 8 and you expressed your reservations about using reflection for that, but I am not sure how that relates to this particular issue. Here the user wants to pass a string with "{NULL}" in it but it fails because we are assuming it is a MessageFormatMessage instead of just a StringMessage.
> Log4J JUL adapter is using MessageFormat on String passed by Supplier<String>
> -----------------------------------------------------------------------------
>
> Key: LOG4J2-1158
> URL: https://issues.apache.org/jira/browse/LOG4J2-1158
> Project: Log4j 2
> Issue Type: Bug
> Components: JUL adapter
> Affects Versions: 2.4
> Environment: Window 7 Business 64 bit
> Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
> Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
> (log4j-jul-2.4.jar, log4j-core-2.4.jar, log4j-api-2.4.jar)
> Reporter: Michael Fortin
> Priority: Minor
>
> Log4J JUL is attempting to _MessageFormat_ a String passed by _*java.util.logging*_.Logger.info(java.util.function._Supplier_<*String*>) and fails with java.lang._*IllegalArgumentException*_ when the String contains *_{ }_*.
> In the following example, line #2 will throw an _*IllegalArgumentException*_:
> {code:java}// writing the configuration file on the fly for the purpose of this demo only
> try (java.io.PrintStream p = new java.io.PrintStream("./log4j-jul-test.xml")) {
> p.println("<Configuration/>");
> }
> // specifying the java.util.logging.LogManager implementation
> System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
> System.setProperty("log4j.configurationFile", "log4j-jul-test.xml");
> java.util.logging.LogManager.getLogManager().getLogger("test").severe("This 1st {will} be logged correctly by log4J");
> // output is: 11:15:40.492 [main] ERROR test - This 1st {will} be logged correctly by log4J
> java.util.logging.LogManager.getLogManager().getLogger("test").severe(() -> "This 2nd {will not} be logged correctly by log4J");
> // output is: 2015-10-10 11:15:40,523 main ERROR An exception occurred processing Appender Console java.lang.IllegalArgumentException: can't parse argument number: will not
> // at java.text.MessageFormat.makeFormat(MessageFormat.java:1429)
> // at java.text.MessageFormat.applyPattern(MessageFormat.java:479){code}
> See also example on http://stackoverflow.com/a/33050986/495987
--
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