Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3281

Log4j 1.2 bridge PropertiesConfiguration.buildAppender not adding filters to custom appender

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 2.17.1, 2.17.0
    • 2.17.2
    • Appenders, Configurators
    • None

    Description

      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 - where the scenario is the same (properties file config):

      log4j1.compatibility=true
      
      log4j.appender.LOG_REQUEST_START_DB=my.appender.class
      log4j.appender.LOG_REQUEST_START_DB.filter.ID=my.filter.class 

      the Filter class I'm working with is the following:

      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;
          }
      } 

      I am using the following log4j dependencies:

              <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> 

      Attachments

        Activity

          People

            Unassigned Unassigned
            coredumped Fábio Constantino
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: