Class RegexFilter
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.filter.AbstractFilter
-
- org.apache.logging.log4j.core.filter.RegexFilter
-
- All Implemented Interfaces:
Filter,LifeCycle,LifeCycle2
@Plugin(name="RegexFilter", category="Core", elementType="filter", printObject=true) public final class RegexFilter extends AbstractFilter
A filter that matches the given regular expression pattern against messages.
-
-
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RegexFiltercreateFilter(String regex, String[] patternFlags, Boolean useRawMsg, Filter.Result match, Filter.Result mismatch)Creates a Filter that matches a regular expression.Filter.Resultfilter(LogEvent event)Context Filter method.Filter.Resultfilter(Logger logger, Level level, Marker marker, Object msg, Throwable t)Appender Filter method.Filter.Resultfilter(Logger logger, Level level, Marker marker, String msg, Object... params)Appender Filter method.Filter.Resultfilter(Logger logger, Level level, Marker marker, Message msg, Throwable t)Appender Filter method.StringtoString()-
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilter
equalsImpl, filter, filter, filter, filter, filter, filter, filter, filter, filter, filter, 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 Detail
-
filter
public Filter.Result filter(Logger logger, Level level, Marker marker, String msg, Object... params)
Description copied from class:AbstractFilterAppender Filter method. The default returns NEUTRAL.- Specified by:
filterin interfaceFilter- Overrides:
filterin classAbstractFilter- 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, Level level, Marker marker, Object msg, Throwable t)
Description copied from class:AbstractFilterAppender Filter method. The default returns NEUTRAL.- Specified by:
filterin interfaceFilter- Overrides:
filterin classAbstractFilter- 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, Level level, Marker marker, Message msg, Throwable t)
Description copied from class:AbstractFilterAppender Filter method. The default returns NEUTRAL.- Specified by:
filterin interfaceFilter- Overrides:
filterin classAbstractFilter- 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)
Description copied from class:AbstractFilterContext Filter method. The default returns NEUTRAL.- Specified by:
filterin interfaceFilter- Overrides:
filterin classAbstractFilter- Parameters:
event- The LogEvent.- Returns:
- The Result of filtering.
-
toString
public String toString()
- Overrides:
toStringin classAbstractFilter
-
createFilter
@PluginFactory public static RegexFilter createFilter(@PluginAttribute("regex") String regex, @PluginElement("PatternFlags") String[] patternFlags, @PluginAttribute("useRawMsg") Boolean useRawMsg, @PluginAttribute("onMatch") Filter.Result match, @PluginAttribute("onMismatch") Filter.Result mismatch) throws IllegalArgumentException, IllegalAccessException
Creates a Filter that matches a regular expression.- Parameters:
regex- The regular expression to match.patternFlags- An array of Strings where each String is aPattern.compile(String, int)compilation flag.useRawMsg- Iftrue, forParameterizedMessage,StringFormattedMessage, andMessageFormatMessage, the message format pattern; forStructuredDataMessage, the message field will be used as the match target.match- The action to perform when a match occurs.mismatch- The action to perform when a mismatch occurs.- Returns:
- The RegexFilter.
- Throws:
IllegalAccessException- When there is no access to the definition of the specified member.IllegalArgumentException- When passed an illegal or inappropriate argument.
-
-