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

java.lang.Object
  extended by org.apache.logging.log4j.core.filter.FilterBase
All Implemented Interfaces:
Filter, Lifecycle
Direct Known Subclasses:
BurstFilter, DynamicThresholdFilter, MapFilter, MarkerFilter, RegexFilter, ThreadContextMapFilter, ThresholdFilter, TimeFilter

public abstract class FilterBase
extends Object
implements Filter, Lifecycle

Users should extend this class to implement filters. Filters can be either context wide or attached to an appender. A filter may choose to support being called only from the context or only from an appender in which case it will only implement the required method(s). The rest will default to return NEUTRAL.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.Filter
Filter.Result
 
Field Summary
protected static org.apache.logging.log4j.Logger LOGGER
          Allow subclasses access to the status logger without creating another instance.
protected  Filter.Result onMatch
          The onMatch Result.
protected  Filter.Result onMismatch
          The onMismatch Result.
 
Constructor Summary
protected FilterBase()
          The default constructor.
protected FilterBase(Filter.Result onMatch, Filter.Result onMismatch)
          Constructor that allows the onMatch and onMismatch actions to be set.
 
Method Summary
 Filter.Result filter(LogEvent event)
          Context Filter method.
 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)
          Appender Filter method.
 Filter.Result filter(Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, Object msg, Throwable t)
          Appender Filter method.
 Filter.Result filter(Logger logger, org.apache.logging.log4j.Level level, org.apache.logging.log4j.Marker marker, String msg, Object[] params)
          Appender Filter method.
 Filter.Result getOnMatch()
          Return the Result to be returned when a match occurs.
 Filter.Result getOnMismatch()
          Return the Result to be returned when a match does not occur.
 boolean isStarted()
          Determine if the the Filter has started.
 void start()
          Mark the Filter as started.
 void stop()
          Mark the Filter as stopped.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOGGER

protected static final org.apache.logging.log4j.Logger LOGGER
Allow subclasses access to the status logger without creating another instance.


onMatch

protected final Filter.Result onMatch
The onMatch Result.


onMismatch

protected final Filter.Result onMismatch
The onMismatch Result.

Constructor Detail

FilterBase

protected FilterBase()
The default constructor.


FilterBase

protected FilterBase(Filter.Result onMatch,
                     Filter.Result onMismatch)
Constructor that allows the onMatch and onMismatch actions to be set.

Parameters:
onMatch - The result to return when a match occurs.
onMismatch - The result to return when a match dos not occur.
Method Detail

start

public void start()
Mark the Filter as started.

Specified by:
start in interface Lifecycle

isStarted

public boolean isStarted()
Determine if the the Filter has started.

Specified by:
isStarted in interface Lifecycle
Returns:
true if the Filter is started, false otherwise.

stop

public void stop()
Mark the Filter as stopped.

Specified by:
stop in interface Lifecycle

getOnMismatch

public final Filter.Result getOnMismatch()
Return the Result to be returned when a match does not occur.

Specified by:
getOnMismatch in interface Filter
Returns:
the onMismatch Result.

getOnMatch

public final Filter.Result getOnMatch()
Return the Result to be returned when a match occurs.

Specified by:
getOnMatch in interface Filter
Returns:
the onMatch Result.

toString

public String toString()
Overrides:
toString in class Object

filter

public Filter.Result filter(Logger logger,
                            org.apache.logging.log4j.Level level,
                            org.apache.logging.log4j.Marker marker,
                            String msg,
                            Object[] params)
Appender Filter method. The default returns NEUTRAL.

Specified by:
filter in interface Filter
Parameters:
logger - the Logger.
level - The logging Level.
marker - The Marker, if any.
msg - The message, if present.
params - An array of parameters or null.
Returns:
The Result of filtering.

filter

public Filter.Result filter(Logger logger,
                            org.apache.logging.log4j.Level level,
                            org.apache.logging.log4j.Marker marker,
                            Object msg,
                            Throwable t)
Appender Filter method. The default returns NEUTRAL.

Specified by:
filter in interface Filter
Parameters:
logger - the Logger.
level - The logging Level.
marker - The Marker, if any.
msg - The message, if present.
t - A throwable or null.
Returns:
The Result of filtering.

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)
Appender Filter method. The default returns NEUTRAL.

Specified by:
filter in interface Filter
Parameters:
logger - the Logger.
level - The logging Level.
marker - The Marker, if any.
msg - The message, if present.
t - A throwable or null.
Returns:
The Result of filtering.

filter

public Filter.Result filter(LogEvent event)
Context Filter method. The default returns NEUTRAL.

Specified by:
filter in interface Filter
Parameters:
event - The LogEvent.
Returns:
The Result of filtering.


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.