[ 
https://issues.apache.org/jira/browse/LOG4J2-631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13994458#comment-13994458
 ] 

Alexandre Gattiker commented on LOG4J2-631:
-------------------------------------------

[~jvz], could we key by both name and MessageFactory?

My use case is that I have a code base that uses the standard MessageFactory, 
but I would like to introduce one logging statement that can benefit from 
FormatterLogger. It is very impractical to have a mix of various log formatters 
over a code base, so my idea was to use the a different name for an additional, 
'non-standard' logger.

If this limitation is to remain, I think it is only practical to use the 
formatter logger exclusively and uniformly over a code base. But then, as it is 
vastly superior to the standard formatter, why not advertise it as the 
recommended usage in Log4j2? It is no more difficult to write %s than {}.

[~garydgregory], I agree it would make sense to document this limitation where 
getFormatterLogger is introduced in 
http://logging.apache.org/log4j/2.x/manual/api.html 

> Cannot use formatter logger and standard logger with same name
> --------------------------------------------------------------
>
>                 Key: LOG4J2-631
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-631
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.0-rc1
>            Reporter: Alexandre Gattiker
>
> {code}
> public class Example {
>       private final static Logger FORMATTER_LOGGER = 
> LogManager.getFormatterLogger(Example.class);
>       private final static Logger LOGGER = 
> LogManager.getLogger(Example.class);
>       public static void main(String[] args) {
>               LOGGER.log(ERROR, "{} happened", "Something");
>               FORMATTER_LOGGER.log(ERROR, "%s happened", "Something");
>       }
> }
> {code}
> {noformat}
> 13:40:35.401 [main] ERROR com.example.Example - {} happened
> 13:40:35.404 [main] ERROR com.example.Example - Something happened
> {noformat}
> After inverting the two constant declarations:
> {noformat}
> 13:41:13.730 [main] ERROR com.example.Example - Something happened
> 13:41:13.732 [main] ERROR com.example.Example - %s happened
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to