Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1180

Logger cache does not account for message factory

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.1
    • 2.5, 2.6.1
    • API
    • None

    Description

      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:

      Logger loggerA1 = LogManager.getLogger("A", messageFactory1);
      Logger loggerA2 = LogManager.getLogger("A", messageFactory2);
      

      loggerA1 is the same as loggerA2.

      This is a problem if two unrelated code bases (jars) both the same Logger names|objects|classes.

      Attachments

        1. LOG4J2-1180.diff
          3 kB
          Gary D. Gregory
        2. LOG4J2-1180-ggregory.patch
          21 kB
          Gary D. Gregory

        Issue Links

          Activity

            People

              ggregory Gary D. Gregory
              ggregory Gary D. Gregory
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: