Class AbstractFilter
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilter
- All Implemented Interfaces:
Filter
,LifeCycle
,LifeCycle2
- Direct Known Subclasses:
BurstFilter
,DenyAllFilter
,DynamicThresholdFilter
,LevelMatchFilter
,LevelRangeFilter
,MapFilter
,MarkerFilter
,MutableThreadContextMapFilter
,NoMarkerFilter
,RegexFilter
,ScriptFilter
,StringMatchFilter
,ThresholdFilter
,TimeFilter
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
Filter.Result.NEUTRAL
.
Garbage-free note: the methods with unrolled varargs by default delegate to the
filter method with vararg parameters
.
Subclasses that want to be garbage-free should override these methods to implement the appropriate filtering
without creating a vararg array.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
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
Modifier and TypeFieldDescriptionprotected final Filter.Result
The onMatch Result.protected final Filter.Result
The onMismatch Result.Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
Fields inherited from interface org.apache.logging.log4j.core.Filter
ELEMENT_TYPE, EMPTY_ARRAY
-
Constructor Summary
ModifierConstructorDescriptionprotected
The default constructor.protected
AbstractFilter
(Filter.Result onMatch, Filter.Result onMismatch) Constructor that allows the onMatch and onMismatch actions to be set. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
equalsImpl
(Object obj) Context Filter method.Appender Filter method.Appender Filter method.Appender Filter method.Appender Filter method.Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) Appender Filter method.filter
(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) Appender Filter method.Appender Filter method.final Filter.Result
Returns the Result to be returned when a match occurs.final Filter.Result
Returns the Result to be returned when a match does not occur.protected int
toString()
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
getState, getStatusLogger, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop, stop
-
Field Details
-
onMatch
The onMatch Result. -
onMismatch
The onMismatch Result.
-
-
Constructor Details
-
AbstractFilter
protected AbstractFilter()The default constructor. -
AbstractFilter
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 Details
-
equalsImpl
- Overrides:
equalsImpl
in classAbstractLifeCycle
-
filter
Context Filter method. The default returns NEUTRAL. -
filter
Appender Filter method. The default returns NEUTRAL. -
filter
Appender Filter method. The default returns NEUTRAL. -
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object... params) Appender Filter method. The default returns NEUTRAL. -
filter
Appender Filter method. The default returns NEUTRAL. -
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1) Appender Filter method. The default returns NEUTRAL. -
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2) Appender Filter method. The default returns NEUTRAL. -
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parametersp7
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parametersp7
- the message parametersp8
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6, Object p7, Object p8, Object p9) Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parametersp2
- the message parametersp3
- the message parametersp4
- the message parametersp5
- the message parametersp6
- the message parametersp7
- the message parametersp8
- the message parametersp9
- the message parameters- Returns:
- The Result of filtering.
- Since:
- 2.7
-
getOnMatch
Returns the Result to be returned when a match occurs.- Specified by:
getOnMatch
in interfaceFilter
- Returns:
- the onMatch Result.
-
getOnMismatch
Returns the Result to be returned when a match does not occur.- Specified by:
getOnMismatch
in interfaceFilter
- Returns:
- the onMismatch Result.
-
hashCodeImpl
protected int hashCodeImpl()- Overrides:
hashCodeImpl
in classAbstractLifeCycle
-
toString
-