Uploaded image for project: 'JBoss Logging'
  1. JBoss Logging
  2. JBLOGGING-160

Log Level Changes from OFF to DEBUG when using Log4j LogManager

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • 3.4.3.Final
    • jboss-logging-log4j
    • None
    • Hide

      I set up 2 GitHub projects to show the issue:
      https://github.com/cquoss/log4j-log-msg-producer'
      This first one is merely to produce log messages using log4j 1.x.
      https://github.com/cquoss/log4j-jboss-logmanager-level-off-bug
      This second project makes use of the first one. When you build both projects locally and run the test on the second one you will notice these log outputs in file target/test.log:
      2022-01-24 18:29:50,250 [log4j] [main] DEBUG de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Debug message
      2022-01-24 18:29:50,295 [log4j] [main] INFO de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Info message
      2022-01-24 18:29:50,296 [log4j] [main] WARN de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Warn message
      2022-01-24 18:29:50,296 [log4j] [main] ERROR de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Error message
      2022-01-24 18:29:50,296 [log4j] [main] FATAL de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Fatal message
      2022-01-24 18:29:50,305 [after] [main] DEBUG de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Debug message
      2022-01-24 18:29:50,306 [after] [main] INFO de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Info message
      2022-01-24 18:29:50,306 [after] [main] WARN de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Warn message
      2022-01-24 18:29:50,306 [after] [main] ERROR de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Error message
      2022-01-24 18:29:50,307 [after] [main] FATAL de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Fatal message

      I used MDC qualifiers to tag the log messages. The messages tagged with 'before' are suppressed as expected because of root log level OFF.

      But starting with the Log4j 1.x DEBUG log message log messages are displayed again because some malfunction in the code switched the root log level to DEBUG.

      Show
      I set up 2 GitHub projects to show the issue: https://github.com/cquoss/log4j-log-msg-producer' This first one is merely to produce log messages using log4j 1.x. https://github.com/cquoss/log4j-jboss-logmanager-level-off-bug This second project makes use of the first one. When you build both projects locally and run the test on the second one you will notice these log outputs in file target/test.log: 2022-01-24 18:29:50,250 [log4j] [main] DEBUG de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Debug message 2022-01-24 18:29:50,295 [log4j] [main] INFO de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Info message 2022-01-24 18:29:50,296 [log4j] [main] WARN de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Warn message 2022-01-24 18:29:50,296 [log4j] [main] ERROR de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Error message 2022-01-24 18:29:50,296 [log4j] [main] FATAL de.quoss.test.log.producer.log4j.Log4jLogMsgProducer Log4j Logger Fatal message 2022-01-24 18:29:50,305 [after] [main] DEBUG de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Debug message 2022-01-24 18:29:50,306 [after] [main] INFO de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Info message 2022-01-24 18:29:50,306 [after] [main] WARN de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Warn message 2022-01-24 18:29:50,306 [after] [main] ERROR de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Error message 2022-01-24 18:29:50,307 [after] [main] FATAL de.quoss.bug.jboss.logmananger.log4j.Main JBoss Logger Fatal message I used MDC qualifiers to tag the log messages. The messages tagged with 'before' are suppressed as expected because of root log level OFF. But starting with the Log4j 1.x DEBUG log message log messages are displayed again because some malfunction in the code switched the root log level to DEBUG.

      When setting the log level to OFF the log level switches to DEBUG when using the Log4j 1.x LogManager in your project.

      Looks like maybe it's simply Level.OFF entry is missing in the map here:
      https://github.com/jboss-logging/log4j-jboss-logmanager/blob/49d37c34732ad060a7464dc4f571bdbde0a00a32/src/main/java/org/apache/log4j/JBossLevelMapping.java#L25

      Already forked the project and will test this.

      Maybe i can then provide a PR for this.

      Here you are:

      https://github.com/jboss-logging/log4j-jboss-logmanager/pull/32

      This works in my tests. Hopefully no other side effects included.

            jperkins-rhn James Perkins
            cquoss Clemens QuoƟ (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: