Class RegexFilter

    • Field Detail

      • pattern

        private final java.util.regex.Pattern pattern
      • useRawMessage

        private final boolean useRawMessage
    • Constructor Detail

      • RegexFilter

        private RegexFilter​(boolean raw,
                            java.util.regex.Pattern pattern,
                            Filter.Result onMatch,
                            Filter.Result onMismatch)
    • 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.
      • targetMessageTest

        private java.lang.String targetMessageTest​(Message message)
      • filter

        private Filter.Result filter​(java.lang.String msg)
      • 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 Strings where each String is a Pattern.compile(String, int) compilation flag.
        useRawMsg - If true, for ParameterizedMessage, StringFormattedMessage, and MessageFormatMessage, the message format pattern; for StructuredDataMessage, 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:
        java.lang.IllegalAccessException - When there is no access to the definition of the specified member.
        java.lang.IllegalArgumentException - When passed an illegal or inappropriate argument.
      • toPatternFlags

        private static int toPatternFlags​(java.lang.String[] patternFlags)
                                   throws java.lang.IllegalArgumentException,
                                          java.lang.IllegalAccessException
        Throws:
        java.lang.IllegalArgumentException
        java.lang.IllegalAccessException