Class RegexFilter

  • All Implemented Interfaces:
    Filter, LifeCycle, LifeCycle2

    @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.
    • Method Detail

      • filter

        public Filter.Result filter​(Logger logger,
                                    Level level,
                                    Marker marker,
                                    java.lang.String msg,
                                    java.lang.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,
                                    Level level,
                                    Marker marker,
                                    java.lang.Object msg,
                                    java.lang.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,
                                    Level level,
                                    Marker marker,
                                    Message msg,
                                    java.lang.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.
      • createFilter

        @PluginFactory
        public static RegexFilter createFilter​(@PluginAttribute("regex")
                                               java.lang.String regex,
                                               @PluginElement("PatternFlags")
                                               java.lang.String[] patternFlags,
                                               @PluginAttribute("useRawMsg")
                                               java.lang.Boolean useRawMsg,
                                               @PluginAttribute("onMatch")
                                               Filter.Result match,
                                               @PluginAttribute("onMismatch")
                                               Filter.Result mismatch)
                                        throws java.lang.IllegalArgumentException,
                                               java.lang.IllegalAccessException
        Creates 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:
        java.lang.IllegalAccessException
        java.lang.IllegalArgumentException