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

Use a class' canonical name instead of name to create its logger name

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.9.0, 2.9.1
    • Component/s: API
    • Labels:
      None

      Description

      Use a class' canonical name instead of name to create its logger name.

      Say you have loggers built with Classes for which getName() give you:

      • com.example.app.A
      • com.example.app.A$AS1
      • com.example.app.A$AS2
      • ...
      • com.example.app.A$ASN

      Before 2.9.0: You you set the root logger to WARN and com.example.app.A to INFO, then you get INFO events for A but you do not get INFO messages from AS1, AS2, and so on. There is no way to set all A$ASx loggers to the same level at the same time.

      In 2.9.0 now, converting a Class to a logger name uses getCannonicalName() such that the logger names are:

      • com.example.app.A
      • com.example.app.A.AS1
      • com.example.app.A.AS2
      • ...
      • com.example.app.A.ASN

      When you set com.example.app.A to INFO, then you get INFO events for A, AS1, AS2, and so on.

      The dev ML thread is:

      https://lists.apache.org/thread.html/43b83474aad9c8625e5a6a63d2595c9d795dd6a51076493bacd87a36@%3Cdev.logging.apache.org%3E

      Note post 2.9.0: If the class canonical name is null, then use the class name.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                garydgregory Gary Gregory
                Reporter:
                garydgregory Gary Gregory
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: