You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Fábio Constantino (Jira)" <ji...@apache.org> on 2022/01/03 10:55:00 UTC
[jira] [Comment Edited] (LOG4J2-3281) PropertiesConfiguration.buildAppender not adding filters to custom appender
[ https://issues.apache.org/jira/browse/LOG4J2-3281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17467926#comment-17467926 ]
Fábio Constantino edited comment on LOG4J2-3281 at 1/3/22, 10:54 AM:
---------------------------------------------------------------------
[~ggregory]
Just tested working with the snapshot version but the problem remains. Checking the code it seems the change in your commit for the _buildAppender_ method in the _PropertiesConfiguration_ class is not present in the snapshot:
({_}parseAppenderFilters(props, filterPrefix, appenderName);{_} -> {_}appender.addFilter(parseAppenderFilters(props, filterPrefix, appenderName));{_})
I am working with the 2.17.2-SNAPSHOT version using maven. Also checked the jar file directly by adding it to my build path - [https://repository.apache.org/content/repositories/snapshots/org/apache/logging/log4j/log4j-1.2-api/2.17.2-SNAPSHOT/log4j-1.2-api-2.17.2-20220101.224329-20.jar] - with the same result.
was (Author: JIRAUSER282085):
[~ggregory]
Just tested working with the snapshot version but the problem remains. Checking the code it seems the change in your commit for the _buildAppender_ method in the _PropertiesConfiguration_ class is not present in the snapshot:
({_}parseAppenderFilters(props, filterPrefix, appenderName);{_} -> \{_}appender.addFilter(parseAppenderFilters(props, filterPrefix, appenderName));{_})
> PropertiesConfiguration.buildAppender not adding filters to custom appender
> ---------------------------------------------------------------------------
>
> Key: LOG4J2-3281
> URL: https://issues.apache.org/jira/browse/LOG4J2-3281
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders, Configurators
> Affects Versions: 2.17.1, 2.17.0
> Reporter: Fábio Constantino
> Priority: Blocker
> Fix For: 2.17.2
>
>
> When building an appender, the _parseAppenderFilters_ method correctly finds my custom filter configuration in the properties file, builds it and returns it, but the caller ({_}buildAppender{_} method) does nothing with it resulting in the appender not having any filters added to it.
>
> This is related to the linked issue - [LOG4J2-3247|https://issues.apache.org/jira/browse/LOG4J2-3247] - where the scenario is the same (properties file config):
> {code:java}
> log4j1.compatibility=true
> log4j.appender.LOG_REQUEST_START_DB=my.appender.class
> log4j.appender.LOG_REQUEST_START_DB.filter.ID=my.filter.class {code}
> the Filter class I'm working with is the following:
> {code:java}
> import org.apache.log4j.spi.Filter;
> import org.apache.log4j.spi.LoggingEvent;
> public class MonitorFilter extends Filter {
> @Override
> public int decide(LoggingEvent event) {
> String requestId = (String)event.getMDC("requestId");
> if (StringHelper.isNullOrEmpty(requestId))
> return DENY;
>
> if (!MonitorScriptManager.getInstance().getMonitorScript().filter(event))
> return DENY;
>
> return ACCEPT;
> }
> } {code}
> I am using the following log4j dependencies:
> {code:java}
> <dependency>
> <groupId>org.apache.logging.log4j</groupId>
> <artifactId>log4j-core</artifactId>
> <version>2.17.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.logging.log4j</groupId>
> <artifactId>log4j-api</artifactId>
> <version>2.17.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.logging.log4j</groupId>
> <artifactId>log4j-1.2-api</artifactId>
> <version>2.17.0</version>
> </dependency> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)