Jacob Tolar created LOG4J2-2123:
-----------------------------------

             Summary: logger filter in composite logger not combined properly
                 Key: LOG4J2-2123
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2123
             Project: Log4j 2
          Issue Type: Bug
            Reporter: Jacob Tolar


When using a composite logger with DefaultMergeStrategy, logger filters aren't 
combined properly. 

Specifically, if the 'parent' configuration for the logger has no filter and 
the child configuration does, all attributes and children of the child filter 
are dropped from the composite configuration. 

For example, if my parent logger has:

{code}
    <Loggers>
        <Logger name="cat1" level="debug" additivity="false">
            <AppenderRef ref="File"/>
        </Logger>
{code}

and the child logger has:
{code}
    <Loggers>
        <Logger name="cat1" level="debug" additivity="false">
            <RegexFilter regex=".*TEST.*" onMatch="DENY" onMismatch="ACCEPT" />
            <AppenderRef ref="File"/>
        </Logger>
{code}

DefaultMergeStrategy creates a RegexFilter node in the composite configuration 
with no attributes. You end up getting a message like this when the RegexFilter 
is constructed:

{code}
2017-11-21 12:02:26,733 main ERROR A regular expression must be provided for 
RegexFilter
{code}

Here: 
https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/DefaultMergeStrategy.java#L172-L174

A new copy of the filter node is created, but the children and attributes 
aren't added to the new nodes.

If the parent logger config does have a filter, it looks like it works 
correctly.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to