[
https://issues.apache.org/jira/browse/LOG4J2-1158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14957791#comment-14957791
]
Gary Gregory commented on LOG4J2-1158:
--------------------------------------
I think you are right based on this new test:
{{org.apache.logging.log4j.jul.AbstractLoggerTest.testLogParamMarkers()}}.
I think we need a custom JUL message that knows how to only handle \{0}, \{1},
and so on.
> Log4J JUL adapter is using MessageFormat on String passed by
> java.util.function.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, 2.4.1
> 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
> Assignee: Gary Gregory
> Priority: Minor
> Fix For: 2.5
>
>
> 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: [email protected]
For additional commands, e-mail: [email protected]