Log4j 2
  1. Log4j 2
  2. LOG4J2-219

Named logger without root logger ends up with empty Appenders map - does not log anything


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta5
    • Fix Version/s: 2.0-beta6
    • Component/s: Core
    • Labels:


      On the log4j-user mailing list, Peter DePasquale gave this test case that demonstrates the problem:

      Note that the configuration has no root logger, but only contains a named logger.

      In a debugger I found that the LoggerConfig for "logtest.LogTest" ended up with an empty "appenders" Map<String, AppenderControl<?>>. The appenderRefs list did contain an AppenderRef object but in #callAppenders there are no AppenderControl objects to call...

      (Sorry, I have been unable to find out the underlying cause yet.)

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration status="warn">
      <File name="tracelog" fileName="trace-log.txt"
      immediateFlush="true" append="false">
      <PatternLayout pattern="%d


      [%t] %-5level %logger


      - %msg%n"/>

      <logger name="logtest.LogTest" level="trace">
      <appender-ref ref="tracelog"/>

      package logtest;
      import org.apache.logging.log4j.LogManager;
      import org.apache.logging.log4j.Logger;
      import org.apache.logging.log4j.core.config.XMLConfigurationFactory;

      public class LogTest {
      public static void main(String[] args)

      { System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, "log4j2-roottest.xml"); Logger logger = LogManager.getLogger(LogTest.class); logger.trace("This is a trace message"); logger.info("This is an info message"); logger.warn("This is a warning message"); }



        Remko Popma made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Fix Version/s 2.0-beta6 [ 12324340 ]
        Resolution Fixed [ 1 ]
        Remko Popma made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Remko Popma made changes -
        Field Original Value New Value
        Assignee Remko Popma [ remkop@yahoo.com ]
        Remko Popma created issue -


          • Assignee:
            Remko Popma
            Remko Popma
          • Votes:
            0 Vote for this issue
            2 Start watching this issue


            • Created: