Log4j 2
  1. Log4j 2
  2. LOG4J2-637

Log4j2 JMX: Updating the logging level via jConsole doesn't take effect

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-rc2
    • Component/s: JMX
    • Labels:
      None

      Description

      I am trying to configure log4j2 so that

      1. I can access the loggers via JMX and
      2. Change their log levels.
      When I hook everything up, I am able to access the LoggerContext via JConsole, which contains all of my LoggerConfigs.

      Each LoggerConfig show the correct log level with which the application is running. And if I update a log level in any LoggerConfig it call the MBean and update the logging level correctly, which I have inspected via debugging. But the problem is that updating the log level doesn't take any effect. The application keeps on logging with the old logging level.

      For example If I start the application with the XYZ logger with log level DEBUG, and change this log level to FATAL via JConsole, it changes successfully but application keep on logging in DEBUG level.

      If instead of updating the single LoggerConfig if I update the LoggerContext by passing the new xml configuration with updated logging levels it works as expected.

      What should be the problem? Documentation is quite and google refused to help me.

      My Findings:

      As far as I understood this problem is that when I update the Log level in the LoggerConfig via JConsole, log4j2 update the log level via MBean correctly but its not updating the LoggerContext, it simply call the setter method and returns. But in case if I update LoggerCoentext log4j2 create the new context to update itself.

      1. log4j2.xml
        1 kB
        Mansoor Sajjad

        Activity

        Mansoor Sajjad created issue -
        Mansoor Sajjad made changes -
        Field Original Value New Value
        Description I am trying to configure log4j2 so that

        I can access the loggers via JMX and
        change their log levels.
        When I hook everything up, I am able to access the LoggerContext via JConsole, which contains all of my LoggerConfigs.

        Each LoggerConfig show the correct log level with which the application is running. And if I update a log level in any LoggerConfig it call the MBean and update the logging level correctly, which I have inspected via debugging. But the problem is that updating the log level doesn't take any effect. The application keeps on logging with the old logging level.

        For example If I start the application with the XYZ logger with log level DEBUG, and change this log level to FATAL via JConsole, it changes successfully but application keep on logging in DEBUG level.

        If instead of updating the single LoggerConfig if I update the LoggerContext by passing the new xml configuration with updated logging levels it works as expected.

        What should be the problem? Documentation is quite and google refused to help me.

        My Findings:

        As far as I understood this problem is that when I update the Log level in the LoggerConfig via JConsole, log4j2 update the log level via MBean correctly but its not updating the LoggerContext, it simply call the setter method and returns. But in case if I update LoggerCoentext log4j2 create the new context to update itself.
        I am trying to configure log4j2 so that

        1. I can access the loggers via JMX and
        2. Change their log levels.
        When I hook everything up, I am able to access the LoggerContext via JConsole, which contains all of my LoggerConfigs.

        Each LoggerConfig show the correct log level with which the application is running. And if I update a log level in any LoggerConfig it call the MBean and update the logging level correctly, which I have inspected via debugging. But the problem is that updating the log level doesn't take any effect. The application keeps on logging with the old logging level.

        For example If I start the application with the XYZ logger with log level DEBUG, and change this log level to FATAL via JConsole, it changes successfully but application keep on logging in DEBUG level.

        If instead of updating the single LoggerConfig if I update the LoggerContext by passing the new xml configuration with updated logging levels it works as expected.

        What should be the problem? Documentation is quite and google refused to help me.

        My Findings:

        As far as I understood this problem is that when I update the Log level in the LoggerConfig via JConsole, log4j2 update the log level via MBean correctly but its not updating the LoggerContext, it simply call the setter method and returns. But in case if I update LoggerCoentext log4j2 create the new context to update itself.
        Hide
        Gareth Western added a comment -

        Please provide your log4j2 configuration as well

        Show
        Gareth Western added a comment - Please provide your log4j2 configuration as well
        Mansoor Sajjad made changes -
        Attachment log4j2.xml [ 12645007 ]
        Hide
        Mansoor Sajjad added a comment -

        Configuration file attached.

        Show
        Mansoor Sajjad added a comment - Configuration file attached.
        Remko Popma made changes -
        Assignee Remko Popma [ remkop@yahoo.com ]
        Hide
        Jon Wilmoth added a comment -

        There appears to be a missing call to org.apache.logging.log4j.core.LoggerContext to reload the updated config (e.g. updateLoggers(Configuration) or .start(Configuration)) after org.apache.logging.log4j.core.jmx.LoggerConfigAdmin.setLevel(String) is called.

        Show
        Jon Wilmoth added a comment - There appears to be a missing call to org.apache.logging.log4j.core.LoggerContext to reload the updated config (e.g. updateLoggers(Configuration) or .start(Configuration)) after org.apache.logging.log4j.core.jmx.LoggerConfigAdmin.setLevel(String) is called.
        Remko Popma made changes -
        Component/s JMX [ 12320594 ]
        Remko Popma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Remko Popma added a comment -

        Fixed in revision 1602587.
        Please verify and close.

        Show
        Remko Popma added a comment - Fixed in revision 1602587. Please verify and close.
        Remko Popma made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.0-rc2 [ 12326292 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open In Progress In Progress
        30d 22h 5m 1 Remko Popma 14/Jun/14 12:33
        In Progress In Progress Resolved Resolved
        49m 45s 1 Remko Popma 14/Jun/14 13:23

          People

          • Assignee:
            Remko Popma
            Reporter:
            Mansoor Sajjad
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development