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 "Gary Gregory (JIRA)" <ji...@apache.org> on 2015/10/13 09:32:05 UTC

[jira] [Resolved] (LOG4J2-1158) Log4J JUL adapter is using MessageFormat on String passed by java.util.function.Supplier

     [ https://issues.apache.org/jira/browse/LOG4J2-1158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved LOG4J2-1158.
----------------------------------
       Resolution: Fixed
    Fix Version/s: 2.5

In Git master now. Please verify and close.

> 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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org