[ https://issues.apache.org/jira/browse/LOG4J2-1180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15310615#comment-15310615 ]
Ralph Goers edited comment on LOG4J2-1180 at 6/1/16 4:55 PM: ------------------------------------------------------------- I don't know if this has anything to do with the problem, but LoggerRegistry.getOrCreateInnerMap is not thread-safe. It should be using putIfAbsent but if it does it will break the WeakMapFactory since that doesn't use a ConcurrentMap. I am also having a hard time understanding how this message is even possible. First we obtain a logger from the registry using the logger name and message factory as keys. Then we call AbstractLogger.checkMessageFactgory to verify that the Logger returned has the same factory as what was requested. Under what circumstances would the LoggerRegistry return a Logger using a different MessageFactory? was (Author: ralph.go...@dslextreme.com): I don't know if this has anything to do with the problem, but LoggerRegistry.getOrCreateInnerMap is not thread-safe. It should be using putIfAbsent but if it does it will break the WeakMapFactory since that doesn't use a ConcurrentMap. > 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-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org