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 "Remko Popma (JIRA)" <ji...@apache.org> on 2016/03/28 02:06:25 UTC
[jira] [Reopened] (LOG4J2-1180) Logger cache does not account for
message factory
[ https://issues.apache.org/jira/browse/LOG4J2-1180?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Remko Popma reopened LOG4J2-1180:
---------------------------------
Reopening for a potential issue I found while working on this area to address LOG4J2-1318:
[~garydgregory], [~ralph.goers@dslextreme.com], [~mikaelstaldal] can you take a look at SLF4JLoggerContext? It looks like the {{getLogger(String, MessageFactory)}} method currently ignores the MessageFactory, and when I try to fix that in the spirit of LOG4J2-1180, the test in log4j-to-slf4j org.a.l.slf4j.LoggerTest breaks... (getLogger_String_MessageFactoryMismatchNull and getLogger_String_MessageFactoryMismatch)
Is there something special about SLF4J Loggers that they must be unique by name only, not by name/MessageFactory? Or are the current implementation and the test simply wrong - LOG4J2-1180 was not addressed correctly here?
----
Looking further, SLF4JLoggerContext is implemented a bit differently from the other LoggerContext implementations (SimpleLoggerContext, log4j-core LoggerContext and Log4jTaglibLoggerContext): the others all check if the previously registered logger matches the MessageFactory by calling {{AbstractLogger.checkMessageFactory(logger, messageFactory)}}, but SLF4JLoggerContext does not.
Same question: is this a bug or is SLF4JLoggerContext special for some reason and is this difference by design?
> 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
> Assignee: Gary Gregory
> Fix For: 2.5
>
> 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: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org