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

Empty NDC stack logs null

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Duplicate
    • 2.6.2
    • 2.7
    • None
    • None

    Description

      Expected behavior

      When the NDC stack is empty nothing should be logged (regression in log4j 2.x, the functionality behaves this way in log4j 1.2).

      ex. 2016-09-09 09:54:44,212 INFO [main] Main (Main.java:6) - huuhaa

      Actual behavior

      When the NDC stack is empty null is logged.

      ex. 2016-09-09 09:54:44,212 INFO [main] Main (Main.java:6) - huuhaa null

      import org.apache.logging.log4j.LogManager;
      
      public class Main {
      
          public static void main(String[] args) {
              LogManager.getLogger(Main.class).info("huuhaa");
          }
      }
      
      <?xml version="1.0" encoding="UTF-8"?>
      <Configuration>
        <Appenders>
          <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m %x%n"/>
          </Console>
        </Appenders>
        <Loggers>
          <Root level="INFO">
            <AppenderRef ref="STDOUT"/>
          </Root>
        </Loggers>
      </Configuration>
      

      Attachments

        Issue Links

          Activity

            People

              mikaelstaldal Mikael Ståldal
              johno Johno Crawford
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: