You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Vladimir Golev (JIRA)" <ji...@apache.org> on 2013/04/17 15:05:15 UTC

[jira] [Created] (LOG4J2-212) The parent is not set for logger without dot symbol in its name.

Vladimir Golev created LOG4J2-212:
-------------------------------------

             Summary: The parent is not set for logger without dot symbol in its name.
                 Key: LOG4J2-212
                 URL: https://issues.apache.org/jira/browse/LOG4J2-212
             Project: Log4j 2
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0-beta4
         Environment: used XML configuration.
            Reporter: Vladimir Golev


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.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org