Log4j 2
  1. Log4j 2
  2. LOG4J2-212

The parent is not set for logger without dot symbol in its name.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-beta4
    • Fix Version/s: 2.0-beta5
    • Component/s: Core
    • Labels:
      None
    • Environment:

      used XML configuration.

      Description

      Bug in org.apache.logging.log4j.core.config.BaseConfiguration.setParents().

      If logger name doesn't contain dot symbol '.' its parent will not be set. As a result the additivity does not work for such loggers. For example if we define loggers with 'org' or 'java' names, we cant see their events in root. And if logger has no reffered appender its events will be lost.

      Reason:
      Lines 760-761. All logic works only if lastIndexOf('.')>0

      Posible fix:
      if (!name.equals("")) {
      final int i = name.lastIndexOf('.');
      if (i > 0) {
      name = name.substring(0, i);
      LoggerConfig parent = getLoggerConfig(name);
      if (parent == null)

      { parent = root; }

      logger.setParent(parent);
      }
      // posible fix
      if (i==-1)

      { logger.setParent(root); }

      // posible fix end
      }

      Loggers sample config:
      <logger name="org" level="error" additivity="true"/>
      <root level="all">
      <appender-ref ref="STDOUT"/>
      </root>
      In such configuration all logs from 'org' will be lost.

        Activity

          People

          • Assignee:
            Ralph Goers
            Reporter:
            Vladimir Golev
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development