Previous Page | Next Page

Filters

AndFilter


AndFilter Overview

You use AndFilter when you want to log messages that meet multiple criteria. AndFilter syntax allows for two or more subfilter definitions within the AndFilter definition. The subfilters are evaluated to decide whether to accept or deny the log event. AndFilters performs a logical AND operation, using the results of each subfilter evaluation to determine the results of AndFilter.

An example of using AndFilter might be that you want to filter log messages that have a threshold of INFO and that contain the string "New client connection".

You can filter by a single threshold, a range of thresholds, or by string matching.


AndFilter Syntax

<filter class="AndFilter">
<param name="AcceptOnMatch" value="TRUE | FALSE">
<filter class="filter-name">
<param name="filter-parameter" value="filter-parameter-value"/>
<param name="AcceptOnMatch" value="TRUE | FALSE"/>
</filter/>-1
[... <filter class="filter-name">
<param name="filter-parameter-name" value="filter-parameter-value"/>
<param name="AcceptOnMatch" value="TRUE | FALSE"/>
</filter/>-n ]
</filter>

AndFilter Syntax Description

class="AndFilter"

specifies to apply the AND logical operation on the subfilter results to determine whether the log event is accepted by the appender.

name="AcceptOnMatch" value="TRUE | FALSE"

for AndFilter, specifies whether to accept or deny the log event if the result of the logical AND is TRUE. For subfilter definitions, specifies whether to accept or deny the log event if the threshold or string matches. Valid values are TRUE or FALSE.

TRUE

specifies to accept the log event.

FALSE

for AndFilter, StringMatchFilter, and LevelMatchFilter, specifies to deny the log event.

class="filter-name"

specifies the name of a filter to use as an argument to the AND logical operation. Here is a list of valid filters:

  • AndFilter

  • LevelMatchFilter

  • LevelRangeFilter

  • StringMatchFilter

name="filter-parameter-name" value="filter-parameter-value"

specifies the name of a filter parameter and the parameter value that is used to compare with either the log event threshold or the message. The following table shows the filter parameters:

Filter Name Filter Parameter Name Filter Parameter Value
LevelMatchFilter LevelToMatch DEBUG | TRACE | INFO | WARN | ERROR | FATAL
LevelRangeFilter LevelMax

LevelMin

DEBUG | TRACE | INFO | WARN | ERROR | FATAL
StringMatchFilter StringToMatch a character string enclosed in quotation marks
AndFilter AcceptOnMatch TRUE | FALSE

In addition to the AcceptOnMatch parameter, specify two or more filters as arguments to a nested AndFilter.


AndFilter Examples

The following filter accepts log events that have a threshold of INFO and the string RETURN in the following log message:

<filter class="AndFilter">
   <param name="AcceptOnMatch" value="true"/>
   <filter class="LevelMatchFilter">
      <param name="LevelToMatch" value="info"/>
      <param name="AcceptOnMatch" value="true"/>
    </filter>
    <filter class="StringMatchFilter">
       <param name="StringToMatch" value="RETURN"/>
       <param name="AcceptOnMatch" value="true"/>
     </filter>
</filter>

Previous Page | Next Page | Top of Page