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

Logger cache does not account for message factory

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.5, 2.6.1
    • Component/s: API
    • Labels:
      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 Gregory
        2. LOG4J2-1180-ggregory.patch
          21 kB
          Gary Gregory

          Issue Links

            Activity

              People

              • Assignee:
                garydgregory Gary Gregory
                Reporter:
                garydgregory Gary Gregory
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: