Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.core.filter
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:
  Serializable, Filter, LifeCycle

    @Plugin(name="RegexFilter",
            category="Core",
            elementType="filter",
            printObject=true)
    public final class RegexFilter

extends AbstractFilter

This filter returns the onMatch result if the message matches the regular expression. The "useRawMsg" attribute can be used to indicate whether the regular expression should be applied to the result of calling Message.getMessageFormat (true) or Message.getFormattedMessage() (false). The default is false.

See Also:
  Serialized Form

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.filter.AbstractFilter
`onMatch, onMismatch`

Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
`LOGGER`

Fields inherited from interface org.apache.logging.log4j.core.Filter
`ELEMENT_TYPE`

Method Summary
`static RegexFilter` | `createFilter(String regex, String[] patternFlags, Boolean useRawMsg, Filter.Result match, Filter.Result mismatch)` Create a Filter that matches a regular expression.
`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.
`String` | `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, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop`

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
`getState, isStarted, isStopped, start, stop`

Method Detail

### filter

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

  Description copied from class: `AbstractFilter`
  Appender Filter method. The default returns NEUTRAL.

  Specified by:
    `filter` in interface `Filter`
  Overrides:
    `filter` in class `AbstractFilter`
  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)

  Description copied from class: `AbstractFilter`
  Appender Filter method. The default returns NEUTRAL.

  Specified by:
    `filter` in interface `Filter`
  Overrides:
    `filter` in class `AbstractFilter`
  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)

  Description copied from class: `AbstractFilter`
  Appender Filter method. The default returns NEUTRAL.

  Specified by:
    `filter` in interface `Filter`
  Overrides:
    `filter` in class `AbstractFilter`
  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: `AbstractFilter`
  Context Filter method. The default returns NEUTRAL.

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

### toString

    public String toString()

  Overrides:
    `toString` in class `AbstractFilter`

### createFilter

    @PluginFactory
    public static RegexFilter createFilter(@PluginAttribute(value="regex")
                                                         String regex,
                                                         @PluginElement(value="PatternFlags")
                                                         String[] patternFlags,
                                                         @PluginAttribute(value="useRawMsg")
                                                         Boolean useRawMsg,
                                                         @PluginAttribute(value="onMatch")
                                                         Filter.Result match,
                                                         @PluginAttribute(value="onMismatch")
                                                         Filter.Result mismatch)
                                    throws IllegalArgumentException,
                                           IllegalAccessException

  Create a Filter that matches a regular expression.

  Parameters:
    `regex` - The regular expression to match.
    `patternFlags` - An array of Stirngs where each String is a `Pattern.compile(String, int)` compilation flag.
    `useRawMsg` - If true, the raw message will be used, otherwise the formatted message will be used.
    `match` - The action to perform when a match occurs.
    `mismatch` - The action to perform when a mismatch occurs.
  Returns:
    The RegexFilter.
  Throws:
    `IllegalAccessException`
    `IllegalArgumentException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 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.