Class ThresholdFilter
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilter
org.apache.logging.log4j.core.filter.ThresholdFilter
- All Implemented Interfaces:
Filter
,LifeCycle
,LifeCycle2
@Plugin(name="ThresholdFilter",
category="Core",
elementType="filter",
printObject=true)
public final class ThresholdFilter
extends AbstractFilter
This filter returns the onMatch result if the level in the LogEvent is the same or more specific
than the configured level and the onMismatch value otherwise. For example, if the ThresholdFilter
is configured with Level ERROR and the LogEvent contains Level DEBUG then the onMismatch value will
be returned since ERROR events are more specific than DEBUG.
The default Level is ERROR.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
AbstractFilter.AbstractFilterBuilder<B extends AbstractFilter.AbstractFilterBuilder<B>>
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.filter.AbstractFilter
onMatch, onMismatch
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThresholdFilter
createFilter
(Level level, Filter.Result match, Filter.Result mismatch) Creates a ThresholdFilter.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.getLevel()
toString()
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
equalsImpl, getOnMatch, getOnMismatch, hashCodeImpl
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
-
Method Details
-
filter
public Filter.Result filter(Logger logger, Level testLevel, Marker marker, String msg, Object... params) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.testLevel
- 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
Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.testLevel
- 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, Level testLevel, Marker marker, Message msg, Throwable t) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.testLevel
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.t
- A throwable or null.- Returns:
- The Result of filtering.
-
filter
Description copied from class:AbstractFilter
Context Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
event
- The LogEvent.- Returns:
- The Result of filtering.
-
filter
Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- Parameters:
logger
- the Logger.level
- The logging Level.marker
- The Marker, if any.msg
- The message, if present.p0
- the message parametersp1
- the message parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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 parameters- Returns:
- The Result of filtering.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object p0, Object p1, Object p2, Object p3, Object p4) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
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) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
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) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
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) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
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) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
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) Description copied from class:AbstractFilter
Appender Filter method. The default returns NEUTRAL.- Specified by:
filter
in interfaceFilter
- Overrides:
filter
in classAbstractFilter
- 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.
-
getLevel
-
toString
- Overrides:
toString
in classAbstractFilter
-
createFilter
@PluginFactory public static ThresholdFilter createFilter(@PluginAttribute("level") Level level, @PluginAttribute("onMatch") Filter.Result match, @PluginAttribute("onMismatch") Filter.Result mismatch) Creates a ThresholdFilter.- Parameters:
level
- The log Level.match
- The action to take on a match.mismatch
- The action to take on a mismatch.- Returns:
- The created ThresholdFilter.
-