org.apache.logging.log4j.core.filter
Class CompositeFilter

java.lang.Object
  extended by org.apache.logging.log4j.core.AbstractLifeCycle
      extended by org.apache.logging.log4j.core.filter.CompositeFilter
All Implemented Interfaces:
Iterable<Filter>, Filter, LifeCycle

@Plugin(name="filters",
        category="Core",
        printObject=true)
public final class CompositeFilter
extends AbstractLifeCycle
implements Iterable<Filter>, Filter

Composes and invokes one or more filters.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.Filter
Filter.Result
 
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
 
Field Summary
 
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
LOGGER
 
Method Summary
 CompositeFilter addFilter(Filter filter)
           
static CompositeFilter createFilters(Filter[] filters)
          Create a CompositeFilter.
 Filter.Result filter(LogEvent event)
          Filter an event.
 Filter.Result filter(Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, org.apache.logging.log4j.message.Message msg, Throwable t)
          Filter an event.
 Filter.Result filter(Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, Object msg, Throwable t)
          Filter an event.
 Filter.Result filter(Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String msg, Object... params)
          Filter an event.
 List<Filter> getFilters()
           
 Filter.Result getOnMatch()
          Returns the result that should be returned when the filter matches the event.
 Filter.Result getOnMismatch()
          Returns the result that should be returned when the filter does not match the event.
 boolean isEmpty()
          Returns whether this composite contains any filters.
 Iterator<Filter> iterator()
           
 CompositeFilter removeFilter(Filter filter)
           
 int size()
           
 void start()
           
 void stop()
           
 String toString()
           
 
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
getState, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.logging.log4j.core.LifeCycle
isStarted, isStopped
 

Method Detail

addFilter

public CompositeFilter addFilter(Filter filter)

removeFilter

public CompositeFilter removeFilter(Filter filter)

iterator

public Iterator<Filter> iterator()
Specified by:
iterator in interface Iterable<Filter>

getFilters

public List<Filter> getFilters()

isEmpty

public boolean isEmpty()
Returns whether this composite contains any filters.

Returns:
whether this composite contains any filters.

size

public int size()

start

public void start()
Specified by:
start in interface LifeCycle
Overrides:
start in class AbstractLifeCycle

stop

public void stop()
Specified by:
stop in interface LifeCycle
Overrides:
stop in class AbstractLifeCycle

getOnMismatch

public Filter.Result getOnMismatch()
Returns the result that should be returned when the filter does not match the event.

Specified by:
getOnMismatch in interface Filter
Returns:
the Result that should be returned when the filter does not match the event.

getOnMatch

public Filter.Result getOnMatch()
Returns the result that should be returned when the filter matches the event.

Specified by:
getOnMatch in interface Filter
Returns:
the Result that should be returned when the filter matches the event.

filter

public Filter.Result filter(Logger logger,
                            org.apache.logging.log4j.Level level,
                            org.apache.logging.log4j.Marker marker,
                            String msg,
                            Object... params)
Filter an event.

Specified by:
filter in interface Filter
Parameters:
logger - The Logger.
level - The event logging Level.
marker - The Marker for the event or null.
msg - String text to filter on.
params - An array of parameters or null.
Returns:
the Result.

filter

public Filter.Result filter(Logger logger,
                            org.apache.logging.log4j.Level level,
                            org.apache.logging.log4j.Marker marker,
                            Object msg,
                            Throwable t)
Filter an event.

Specified by:
filter in interface Filter
Parameters:
logger - The Logger.
level - The event logging Level.
marker - The Marker for the event or null.
msg - Any Object.
t - A Throwable or null.
Returns:
the Result.

filter

public Filter.Result filter(Logger logger,
                            org.apache.logging.log4j.Level level,
                            org.apache.logging.log4j.Marker marker,
                            org.apache.logging.log4j.message.Message msg,
                            Throwable t)
Filter an event.

Specified by:
filter in interface Filter
Parameters:
logger - The Logger.
level - The event logging Level.
marker - The Marker for the event or null.
msg - The Message
t - A Throwable or null.
Returns:
the Result.

filter

public Filter.Result filter(LogEvent event)
Filter an event.

Specified by:
filter in interface Filter
Parameters:
event - The Event to filter on.
Returns:
the Result.

toString

public String toString()
Overrides:
toString in class Object

createFilters

@PluginFactory
public static CompositeFilter createFilters(@PluginElement(value="Filters")
                                                          Filter[] filters)
Create a CompositeFilter.

Parameters:
filters - An array of Filters to call.
Returns:
The CompositeFilter.


Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.