Class LevelRangeFilter

All Implemented Interfaces:
Filter, LifeCycle, LifeCycle2

@Plugin(name="LevelRangeFilter", category="Core", elementType="filter", printObject=true) public final class LevelRangeFilter extends AbstractFilter
This filter returns the AbstractFilter.onMatch result if the level of the LogEvent is in the range of the configured minLevel and maxLevel values, otherwise it returns the AbstractFilter.onMismatch result. The default values for minLevel and maxLevel are set to Level.OFF and Level.ALL, respectively. The default values for AbstractFilter.onMatch and AbstractFilter.onMismatch are set to Filter.Result.NEUTRAL and Filter.Result.DENY, respectively.

The levels get compared by their associated integral values; Level.OFF has an integral value of 0, Level.FATAL 100, Level.ERROR 200, and so on. For example, if the filter is configured with maxLevel set to Level.INFO, the filter will return AbstractFilter.onMismatch result for LogEvents of level with higher integral values; Level.DEBUG, Level.TRACE, etc.

  • Field Details

    • DEFAULT_MIN_LEVEL

      public static final Level DEFAULT_MIN_LEVEL
      The default minimum level threshold.
    • DEFAULT_MAX_LEVEL

      public static final Level DEFAULT_MAX_LEVEL
      THe default maximum level threshold.
    • DEFAULT_ON_MATCH

      public static final Filter.Result DEFAULT_ON_MATCH
      The default result on a match.
    • DEFAULT_ON_MISMATCH

      public static final Filter.Result DEFAULT_ON_MISMATCH
      The default result on a mismatch.
  • Method Details

    • createFilter

      @PluginFactory public static LevelRangeFilter createFilter(@PluginAttribute("minLevel") Level minLevel, @PluginAttribute("maxLevel") Level maxLevel, @PluginAttribute("onMatch") Filter.Result onMatch, @PluginAttribute("onMismatch") Filter.Result onMismatch)
      Creates an instance with the provided properties.
      Parameters:
      minLevel - the minimum level threshold
      maxLevel - the maximum level threshold
      onMatch - the result to return on a match
      onMismatch - the result to return on a mismatch
      Returns:
      a new instance
    • 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.
    • filter

      public Filter.Result filter(Logger logger, Level level, Marker marker, 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(Logger logger, Level level, 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, Level level, 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, Level level, Marker marker, String msg, Object p0)
      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.
      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 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.
      p0 - the message parameters
      p1 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - the message parameters
      p4 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - the message parameters
      p4 - the message parameters
      p5 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - the message parameters
      p4 - the message parameters
      p5 - the message parameters
      p6 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - the message parameters
      p4 - the message parameters
      p5 - the message parameters
      p6 - the message parameters
      p7 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - the message parameters
      p4 - the message parameters
      p5 - the message parameters
      p6 - the message parameters
      p7 - the message parameters
      p8 - 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 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.
      p0 - the message parameters
      p1 - the message parameters
      p2 - the message parameters
      p3 - the message parameters
      p4 - the message parameters
      p5 - the message parameters
      p6 - the message parameters
      p7 - the message parameters
      p8 - the message parameters
      p9 - the message parameters
      Returns:
      The Result of filtering.
    • getMinLevel

      public Level getMinLevel()
      Returns:
      the minimum level threshold
    • getMaxLevel

      public Level getMaxLevel()
      Returns:
      the maximum level threshold
    • toString

      public String toString()
      Overrides:
      toString in class AbstractFilter