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

Reconfiguring statusLogger to a higher level doesn't work correctly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.3
    • Component/s: Core
    • Labels:
      None

      Description

      When reconfiguring log4j and changing the level of the status logger to a higher level - e.g. from WARN to DEBUG, it doesn't work correctly.

      Steps to reproduce:

      1. Configure from log4j2.xml containing:
        <Configuration status="WARN" monitorInterval="5">
        ...
        
      2. With the app running, change status to a higher level:
        <Configuration status="DEBUG" monitorInterval="5">
        ...
        
      3. Observe that the log config is reloaded, but no debug messages for the status logger appear.

      From what I've seen this is because the StatusConfiguration.initialize() reconfigures the listeners' level
      StatusConfig:193

      But it doesn't update the listenersLevel field that the StatusLogger uses for checking if the logger is enabled (I understand this should be the maximum of all of the listener's levels)

      StatusLogger:273

      So in this case the listenersLevel is still at WARN, even though the console listener has a DEBUG level, and all the log messages are ignored because isEnabled(DEBUG) returns false.

        Attachments

        1. StatusLoggerBenchmark.java
          4 kB
          Stefan Wehner
        2. remove_listeners_level.patch
          3 kB
          Stefan Wehner
        3. log4j2-status-perf.xml
          1 kB
          Stefan Wehner
        4. callback_on_reconfig.patch
          3 kB
          Stefan Wehner

          Issue Links

            Activity

              People

              • Assignee:
                rpopma Remko Popma
                Reporter:
                stefanwehner Stefan Wehner
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: