org.apache.log4j.spi.Filter Java Examples

The following examples show how to use org.apache.log4j.spi.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StringMatchFilterBuilder.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Override
public Filter parseFilter(Element filterElement, XmlConfiguration config) {
    final Holder<Boolean> acceptOnMatch = new BooleanHolder();
    final Holder<String> text = new Holder<>();
    forEachElement(filterElement.getElementsByTagName("param"), (currentElement) -> {
        if (currentElement.getTagName().equals("param")) {
            switch (currentElement.getAttribute(NAME_ATTR)) {
                case STRING_TO_MATCH:
                    text.set(currentElement.getAttribute(VALUE_ATTR));
                    break;
                case ACCEPT_ON_MATCH:
                    acceptOnMatch.set(Boolean.parseBoolean(currentElement.getAttribute(VALUE_ATTR)));
                    break;

            }
        }
    });
    return createFilter(text.get(), acceptOnMatch.get());
}
 
Example #2
Source File: StringMatchFilter.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
    Returns {@link Filter#NEUTRAL} is there is no string match.
  */
 public
 int decide(LoggingEvent event) {
   String msg = event.getRenderedMessage();

   if(msg == null ||  stringToMatch == null)
     return Filter.NEUTRAL;
   

   if( msg.indexOf(stringToMatch) == -1 ) {
     return Filter.NEUTRAL;
   } else { // we've got a match
     if(acceptOnMatch) {
return Filter.ACCEPT;
     } else {
return Filter.DENY;
     }
   }
 }
 
Example #3
Source File: LevelRangeFilterBuilder.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private Filter createFilter(String levelMax, String levelMin, boolean acceptOnMatch) {
    Level max = Level.FATAL;
    Level min = Level.TRACE;
    if (levelMax != null) {
        max = Level.toLevel(levelMax, Level.FATAL);
    }
    if (levelMin != null) {
        min = Level.toLevel(levelMin, Level.DEBUG);
    }
    org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch
            ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
            : org.apache.logging.log4j.core.Filter.Result.NEUTRAL;

    return new FilterWrapper(LevelRangeFilter.createFilter(min, max, onMatch,
            org.apache.logging.log4j.core.Filter.Result.DENY));
}
 
Example #4
Source File: FilterAdapter.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Override
public Result filter(LogEvent event) {
    LoggingEvent loggingEvent = new LogEventAdapter(event);
    Filter next = filter;
    while (next != null) {
        switch (filter.decide(loggingEvent)) {
            case Filter.ACCEPT:
                return Result.ACCEPT;
            case Filter.DENY:
                return Result.DENY;
            default:
        }
        next = filter.getNext();
    }
    return Result.NEUTRAL;
}
 
Example #5
Source File: LevelMatchFilter.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
   Return the decision of this filter.

   Returns {@link Filter#NEUTRAL} if the <b>LevelToMatch</b> option
   is not set or if there is not match.  Otherwise, if there is a
   match, then the returned decision is {@link Filter#ACCEPT} if the
   <b>AcceptOnMatch</b> property is set to <code>true</code>. The
   returned decision is {@link Filter#DENY} if the
   <b>AcceptOnMatch</b> property is set to false.

*/
public
int decide(LoggingEvent event) {
  if(this.levelToMatch == null) {
    return Filter.NEUTRAL;
  }
  
  boolean matchOccured = false;
  if(this.levelToMatch.equals(event.getLevel())) {
    matchOccured = true;
  } 

  if(matchOccured) {  
    if(this.acceptOnMatch)
 return Filter.ACCEPT;
    else
 return Filter.DENY;
  } else {
    return Filter.NEUTRAL;
  }
}
 
Example #6
Source File: AppenderSkeleton.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
  * This method performs threshold checks and invokes filters before
  * delegating actual logging to the subclasses specific {@link
  * AppenderSkeleton#append} method.
  * */
public
synchronized 
void doAppend(LoggingEvent event) {
  if(closed) {
    LogLog.error("Attempted to append to closed appender named ["+name+"].");
    return;
  }
  
  if(!isAsSevereAsThreshold(event.getLevel())) {
    return;
  }

  Filter f = this.headFilter;
  
  FILTER_LOOP:
  while(f != null) {
    switch(f.decide(event)) {
    case Filter.DENY: return;
    case Filter.ACCEPT: break FILTER_LOOP;
    case Filter.NEUTRAL: f = f.getNext();
    }
  }
  
  this.append(event);    
}
 
Example #7
Source File: LevelMatchFilterBuilder.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Override
public Filter parseFilter(Element filterElement, XmlConfiguration config) {
    final Holder<String> level = new Holder<>();
    final Holder<Boolean> acceptOnMatch = new BooleanHolder();
    forEachElement(filterElement.getElementsByTagName("param"), (currentElement) -> {
        if (currentElement.getTagName().equals("param")) {
            switch (currentElement.getAttribute(NAME_ATTR)) {
                case LEVEL:
                    level.set(currentElement.getAttribute(VALUE_ATTR));
                    break;
                case ACCEPT_ON_MATCH:
                    acceptOnMatch.set(Boolean.parseBoolean(currentElement.getAttribute(VALUE_ATTR)));
                    break;
            }
        }
    });
    return createFilter(level.get(), acceptOnMatch.get());
}
 
Example #8
Source File: XmlConfiguration.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
/**
 * Used internally to parse a filter element.
 * @param filterElement The Filter Element.
 * @return The Filter.
 */
public Filter parseFilters(Element filterElement) {
    String className = subst(filterElement.getAttribute(CLASS_ATTR));
    LOGGER.debug("Class name: [" + className + ']');
    Filter filter = manager.parseFilter(className, filterElement, this);
    if (filter == null) {
        PropertySetter propSetter = new PropertySetter(filter);
        forEachElement(filterElement.getChildNodes(), (currentElement) -> {
            String tagName = currentElement.getTagName();
            if (tagName.equals(PARAM_TAG)) {
                setParameter(currentElement, propSetter);
            } else {
                quietParseUnrecognizedElement(filter, currentElement, props);
            }
        });
        propSetter.activate();
    }
    return filter;
}
 
Example #9
Source File: LoggingTester.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private static void removeFilter(final Appender appender, final Filter filter) {
  Filter _filter = appender.getFilter();
  boolean _equals = Objects.equal(_filter, filter);
  if (_equals) {
    appender.clearFilters();
    appender.addFilter(filter.getNext());
  } else {
    for (Filter current = appender.getFilter(); (current != null); current = current.getNext()) {
      Filter _next = current.getNext();
      boolean _equals_1 = Objects.equal(_next, filter);
      if (_equals_1) {
        current.setNext(filter.getNext());
        return;
      }
    }
  }
}
 
Example #10
Source File: RewriteAppenderBuilder.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
@Override
public Appender parseAppender(final String name, final String appenderPrefix, final String layoutPrefix,
        final String filterPrefix, final Properties props, final PropertiesConfiguration configuration) {
    String appenderRef = getProperty(APPENDER_REF_TAG);
    Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
    String policyPrefix = appenderPrefix + ".rewritePolicy";
    String className = getProperty(policyPrefix);
    RewritePolicy policy = configuration.getBuilderManager().parseRewritePolicy(className, policyPrefix,
            props, configuration);
    String level = getProperty(THRESHOLD_PARAM);
    if (appenderRef == null) {
        LOGGER.warn("No appender references configured for AsyncAppender {}", name);
        return null;
    }
    Appender appender = configuration.parseAppender(props, appenderRef);
    if (appender == null) {
        LOGGER.warn("Cannot locate Appender {}", appenderRef);
        return null;
    }
    return createAppender(name, level, new String[] {appenderRef}, policy, filter, configuration);
}
 
Example #11
Source File: ConsoleAppenderBuilder.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private <T extends Log4j1Configuration> Appender createAppender(String name, Layout layout, Filter filter,
        String level, String target, T configuration) {
    org.apache.logging.log4j.core.Layout<?> consoleLayout = null;

    if (layout instanceof LayoutWrapper) {
        consoleLayout = ((LayoutWrapper) layout).getLayout();
    } else if (layout != null) {
        consoleLayout = new LayoutAdapter(layout);
    }
    org.apache.logging.log4j.core.Filter consoleFilter = buildFilters(level, filter);
    ConsoleAppender.Target consoleTarget = SYSTEM_ERR.equals(target)
            ? ConsoleAppender.Target.SYSTEM_ERR : ConsoleAppender.Target.SYSTEM_OUT;
    return new AppenderWrapper(ConsoleAppender.newBuilder()
            .setName(name)
            .setTarget(consoleTarget)
            .setLayout(consoleLayout)
            .setFilter(consoleFilter)
            .setConfiguration(configuration)
            .build());
}
 
Example #12
Source File: KafkaAppender.java    From SkyEye with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 覆写doAppend, 去掉closed的log日志
 * @param event
 */
@Override
public synchronized void doAppend(LoggingEvent event) {
    if (closed) {
        return;
    }

    if (!isAsSevereAsThreshold(event.getLevel())) {
        return;
    }

    Filter f = this.headFilter;

    FILTER_LOOP:
    while(f != null) {
        switch(f.decide(event)) {
            case Filter.DENY: return;
            case Filter.ACCEPT: break FILTER_LOOP;
            case Filter.NEUTRAL: f = f.getNext();
        }
    }

    this.append(event);
}
 
Example #13
Source File: LoggingTester.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private static void removeFilter(final Appender appender, final Filter filter) {
  Filter _filter = appender.getFilter();
  boolean _equals = Objects.equal(_filter, filter);
  if (_equals) {
    appender.clearFilters();
    appender.addFilter(filter.getNext());
  } else {
    for (Filter current = appender.getFilter(); (current != null); current = current.getNext()) {
      Filter _next = current.getNext();
      boolean _equals_1 = Objects.equal(_next, filter);
      if (_equals_1) {
        current.setNext(filter.getNext());
        return;
      }
    }
  }
}
 
Example #14
Source File: Log4jAppenderTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Test
public void addFilter() {
  Appender appender = getAppender();
  Filter filter = mock( Filter.class );
  appender.addFilter( filter );
  assertThat( appender.getFilter(), is( filter ) );
}
 
Example #15
Source File: LevelRangeFilter.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
   Return the decision of this filter.
 */
public
int decide(LoggingEvent event) {
  if(this.levelMin != null) {
    if (event.getLevel().isGreaterOrEqual(levelMin) == false) {
      // level of event is less than minimum
      return Filter.DENY;
    }
  }

  if(this.levelMax != null) {
    if (event.getLevel().toInt() > levelMax.toInt()) {
      // level of event is greater than maximum
      // Alas, there is no Level.isGreater method. and using
      // a combo of isGreaterOrEqual && !Equal seems worse than
      // checking the int values of the level objects..
      return Filter.DENY;
    }
  }

  if (acceptOnMatch) {
    // this filter set up to bypass later filters and always return
    // accept if level in range
    return Filter.ACCEPT;
  }
  else {
    // event is ok for this filter; allow later filters to have a look..
    return Filter.NEUTRAL;
  }
}
 
Example #16
Source File: StringMatchFilterBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private Filter createFilter(String text, boolean acceptOnMatch) {
    if (text == null) {
        LOGGER.warn("No text provided for StringMatchFilter");
        return null;
    }
    org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch
            ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
            : org.apache.logging.log4j.core.Filter.Result.DENY;
    return new FilterWrapper(StringMatchFilter.newBuilder()
            .setMatchString(text)
            .setOnMatch(onMatch)
            .setOnMismatch(org.apache.logging.log4j.core.Filter.Result.NEUTRAL)
            .build());
}
 
Example #17
Source File: Log.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public int decide (LoggingEvent e) {
	Level	l = e.getLevel ();

	if ((l == Level.DEBUG) || (l == Level.INFO) || (l == Level.WARN) || (l == Level.ERROR) || (l == Level.FATAL)) {
		return Filter.ACCEPT;
	}
	return Filter.NEUTRAL;
}
 
Example #18
Source File: BuilderManager.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
public Filter parseFilter(String className, Element filterElement, XmlConfigurationFactory factory) {
    PluginType<?> plugin = plugins.get(className.toLowerCase());
    if (plugin != null) {
        try {
            @SuppressWarnings("unchecked")
            FilterBuilder builder = (FilterBuilder) LoaderUtil.newInstanceOf(plugin.getPluginClass());
            return builder.parseFilter(filterElement, factory);
        } catch (InstantiationException | IllegalAccessException | InvocationTargetException ex) {
            LOGGER.warn("Unable to load plugin: {} due to: {}", plugin.getKey(), ex.getMessage());
        }
    }
    return null;
}
 
Example #19
Source File: LoggingTester.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public int decide(final LoggingEvent event) {
  int _xifexpression = (int) 0;
  String _loggerName = event.getLoggerName();
  String _name = this.source.getName();
  boolean _equals = Objects.equal(_loggerName, _name);
  if (_equals) {
    _xifexpression = Filter.DENY;
  } else {
    _xifexpression = Filter.NEUTRAL;
  }
  return _xifexpression;
}
 
Example #20
Source File: DailyRollingFileAppenderBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Appender parseAppender(final String name, final String appenderPrefix, final String layoutPrefix,
        final String filterPrefix, final Properties props, final PropertiesConfiguration configuration) {
    Layout layout = configuration.parseLayout(layoutPrefix, name, props);
    Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
    String fileName = getProperty(FILE_PARAM);
    String level = getProperty(THRESHOLD_PARAM);
    boolean append = getBooleanProperty(APPEND_PARAM);
    boolean immediateFlush = false;
    boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM);
    int bufferSize = Integer.parseInt(getProperty(BUFFER_SIZE_PARAM, "8192"));
    return createAppender(name, layout, filter, fileName, append, immediateFlush,
            level, bufferedIo, bufferSize, configuration);
}
 
Example #21
Source File: StringMatchFilterBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Filter parseFilter(Element filterElement, XmlConfigurationFactory factory) {
    final Holder<Boolean> acceptOnMatch = new BooleanHolder();
    final Holder<String> text = new Holder<>();
    forEachElement(filterElement.getElementsByTagName("param"), (currentElement) -> {
        if (currentElement.getTagName().equals("param")) {
            switch (currentElement.getAttribute(NAME_ATTR).toLowerCase()) {
                case STRING_TO_MATCH:
                    text.set(currentElement.getAttribute(VALUE_ATTR));
                    break;
                case ACCEPT_ON_MATCH:
                    acceptOnMatch.set(Boolean.parseBoolean(currentElement.getAttribute(VALUE_ATTR)));
                    break;

            }
        }
    });
    if (text.get() == null) {
        LOGGER.warn("No text provided for StringMatchFilter");
        return null;
    }
    org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch.get() != null && acceptOnMatch.get()
            ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
            : org.apache.logging.log4j.core.Filter.Result.DENY;
    return new FilterWrapper(StringMatchFilter.newBuilder()
            .setMatchString(text.get())
            .setOnMatch(onMatch)
            .setOnMismatch(org.apache.logging.log4j.core.Filter.Result.NEUTRAL)
            .build());
}
 
Example #22
Source File: Log4JConfigurationTests.java    From dynamodb-cross-region-library with Apache License 2.0 5 votes vote down vote up
@Test
public void testShardSyncerMessage() throws ClassNotFoundException {
    Logger log = Logger.getRootLogger();
    Appender a = log.getAppender("CONSOLE");
    Filter f = a.getFilter();
    assertEquals(null, f.getNext());
    assertEquals(StringMatchFilter.class, f.getClass());
    assertEquals(Filter.NEUTRAL, a.getFilter().decide(new LoggingEvent(Logger.class.toString(), log, Level.ERROR, "TestMessage", null)));
    assertEquals(Filter.DENY, a.getFilter().decide(new LoggingEvent(Logger.class.toString(), log, Level.ERROR, SHARD_SYNC_MESSAGE, null)));
    assertEquals(Filter.DENY,
        a.getFilter().decide(new LoggingEvent(Logger.class.toString(), log, Level.ERROR, "Shard shard-1234-5432-1234 " + SHARD_SYNC_MESSAGE, null)));
}
 
Example #23
Source File: PrimitiveAuthorityProxy.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public int decide(LoggingEvent event) {
	Object oRunId = event.getMDC(LogUtils.MDC_RUNID_KEY);
	if (!(oRunId instanceof Long))
		return Filter.DENY;
	Long rId = (Long)oRunId;
	if (this.runId != rId.longValue())
		return Filter.DENY;
	else {
		if (event.getLevel().isGreaterOrEqual(logLevel))
			return Filter.ACCEPT;
		else
			return Filter.DENY;
	}
}
 
Example #24
Source File: LevelRangeFilterBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Filter parseFilter(PropertiesConfiguration config) {
    String levelMax = getProperty(LEVEL_MAX);
    String levelMin = getProperty(LEVEL_MIN);
    boolean acceptOnMatch = getBooleanProperty(ACCEPT_ON_MATCH);
    return createFilter(levelMax, levelMin, acceptOnMatch);
}
 
Example #25
Source File: FileAppenderBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Appender parseAppender(final String name, final String appenderPrefix, final String layoutPrefix,
        final String filterPrefix, final Properties props, final PropertiesConfiguration configuration) {
    Layout layout = configuration.parseLayout(layoutPrefix, name, props);
    Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
    String level = getProperty(THRESHOLD_PARAM);
    String fileName = getProperty(FILE_PARAM);
    boolean append = getBooleanProperty(APPEND_PARAM);
    boolean immediateFlush = false;
    boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM);
    int bufferSize = Integer.parseInt(getProperty(BUFFER_SIZE_PARAM, "8192"));
    return createAppender(name, configuration, layout, filter, fileName, level, immediateFlush,
            append, bufferedIo, bufferSize);
}
 
Example #26
Source File: FileAppenderBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private Appender createAppender(final String name, final Log4j1Configuration configuration, final Layout layout,
        final Filter filter, final String fileName, String level, boolean immediateFlush, final boolean append,
        final boolean bufferedIo, final int bufferSize) {
    org.apache.logging.log4j.core.Layout<?> fileLayout = null;
    if (bufferedIo) {
        immediateFlush = true;
    }
    if (layout instanceof LayoutWrapper) {
        fileLayout = ((LayoutWrapper) layout).getLayout();
    } else if (layout != null) {
        fileLayout = new LayoutAdapter(layout);
    }
    org.apache.logging.log4j.core.Filter fileFilter = buildFilters(level, filter);
    if (fileName == null) {
        LOGGER.warn("Unable to create File Appender, no file name provided");
        return null;
    }
    return new AppenderWrapper(FileAppender.newBuilder()
            .setName(name)
            .setConfiguration(configuration)
            .setLayout(fileLayout)
            .setFilter(fileFilter)
            .setFileName(fileName)
            .setImmediateFlush(immediateFlush)
            .setAppend(append)
            .setBufferedIo(bufferedIo)
            .setBufferSize(bufferSize)
            .build());
}
 
Example #27
Source File: LevelRangeFilterBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Filter parseFilter(Element filterElement, XmlConfigurationFactory factory) {
    final Holder<String> levelMax = new Holder<>();
    final Holder<String> levelMin = new Holder<>();
    final Holder<Boolean> acceptOnMatch = new BooleanHolder();
    forEachElement(filterElement.getElementsByTagName("param"), (currentElement) -> {
        if (currentElement.getTagName().equals("param")) {
            switch (currentElement.getAttribute(NAME_ATTR).toLowerCase()) {
                case LEVEL_MAX:
                    levelMax.set(currentElement.getAttribute(VALUE_ATTR));
                    break;
                case LEVEL_MIN:
                    levelMax.set(currentElement.getAttribute(VALUE_ATTR));
                    break;
                case ACCEPT_ON_MATCH:
                    acceptOnMatch.set(Boolean.parseBoolean(currentElement.getAttribute(VALUE_ATTR)));
                    break;
            }
        }
    });
    Level max = Level.FATAL;
    Level min = Level.TRACE;
    if (levelMax.get() != null) {
        max = Level.toLevel(levelMax.get(), Level.FATAL);
    }
    if (levelMin.get() != null) {
        min = Level.toLevel(levelMin.get(), Level.DEBUG);
    }
    org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch.get() != null && acceptOnMatch.get()
            ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
            : org.apache.logging.log4j.core.Filter.Result.NEUTRAL;

    return new FilterWrapper(LevelRangeFilter.createFilter(min, max, onMatch,
            org.apache.logging.log4j.core.Filter.Result.DENY));
}
 
Example #28
Source File: AppenderWrapper.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public void addFilter(Filter newFilter) {
    if (appender instanceof AbstractFilterable) {
        if (newFilter instanceof FilterWrapper) {
            ((AbstractFilterable) appender).addFilter(((FilterWrapper) newFilter).getFilter());
        } else {
            ((AbstractFilterable) appender).addFilter(new FilterAdapter(newFilter));
        }
    } else {
        LOGGER.warn("Unable to add filter to appender {}, it does not support filters", appender.getName());
    }
}
 
Example #29
Source File: RollingFileAppenderBuilder.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
@Override
public Appender parseAppender(final String name, final String appenderPrefix, final String layoutPrefix,
        final String filterPrefix, final Properties props, final PropertiesConfiguration configuration) {
    Layout layout = configuration.parseLayout(layoutPrefix, name, props);
    Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
    String fileName = getProperty(FILE_PARAM);
    String level = getProperty(THRESHOLD_PARAM);
    boolean immediateFlush = false;
    boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM);
    String maxSize = getProperty(MAX_SIZE_PARAM);
    String maxBackups = getProperty(MAX_BACKUP_INDEX);
    return createAppender(name, configuration, layout, filter, bufferedIo, immediateFlush, fileName, level, maxSize,
            maxBackups);
}
 
Example #30
Source File: PropertiesConfiguration.java    From logging-log4j2 with Apache License 2.0 5 votes vote down vote up
private Filter buildFilter(String className, String appenderName, List<NameValue> props) {
    Filter filter = newInstanceOf(className, "Filter");
    if (filter != null) {
        PropertySetter propSetter = new PropertySetter(filter);
        for (NameValue property : props) {
            propSetter.setProperty(property.key, property.value);
        }
        propSetter.activate();
    }
    return filter;
}