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

Gary Gregory commented on LOG4J2-1180:
--------------------------------------

Hi Ralph,

Confused: %C picks up a stack element's class name. Do you mean a different % 
name?

{quote}
Saving the Logger in the map and including the FQCN could be OK, so long as it 
isn't included in the logger name itself.
{quote}
Do you mean something like having a Key class with a Logger name and 
MessageFactory as ivars? And using this Key class as the key instead of String?

Or do you mean using the logger as the key but instead of a Logger value, use a 
map of MessageFactory name to Logger?

I could see that as working, it's a two step process but O(1) + O(1) is still 
O(1).

> Logger cache does not account for message factory
> -------------------------------------------------
>
>                 Key: LOG4J2-1180
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1180
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.4.1
>            Reporter: Gary Gregory
>         Attachments: LOG4J2-1180.diff
>
>
> The Logger cache does not account for a logger's message factory.
> If you call {{LogManager.getLogger(Class|Object|String, MessageFactory)}} and 
> then call a getLogger() API again with the same {{Class|Object|String}} a 
> different message factory, you get the Logger that was first created which 
> means you will not get the proper formatted messages.
> For example:
> {code:java}
> Logger loggerA1 = LogManager.getLogger("A", messageFactory1);
> Logger loggerA2 = LogManager.getLogger("A", messageFactory2);
> {code}
> loggerA1 is the same as loggerA2.
> This is a problem if two unrelated code bases (jars) both the same Logger 
> names|objects|classes.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to