You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Jacob Tolar (JIRA)" <ji...@apache.org> on 2017/12/11 20:46:00 UTC

[jira] [Closed] (LOG4J2-2123) logger filter in composite logger not combined properly

     [ https://issues.apache.org/jira/browse/LOG4J2-2123?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jacob Tolar closed LOG4J2-2123.
-------------------------------

Some sample code and output here comparing before and after the patch: 
https://gist.github.com/jacobtolar/979b6f56a2cfd6eb45e996ab4e494c11#file-output-txt

Looks better. Thank you [~ralph.goers@dslextreme.com]!

> 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
>             Fix For: 2.10.1
>
>
> 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)