Table of Contents

Class LevelMatchFilter

Namespace
log4net.Filter
Assembly
log4net.dll

This is a very simple filter based on Level matching.

public class LevelMatchFilter : FilterSkeleton, IFilter, IOptionHandler
Inheritance
LevelMatchFilter
Implements
Inherited Members

Remarks

The filter admits two options LevelToMatch and AcceptOnMatch. If there is an exact match between the value of the LevelToMatch option and the Level of the LoggingEvent, then the Decide(LoggingEvent) method returns Accept in case the AcceptOnMatch option value is set to true, if it is false then Deny is returned. If the Level does not match then the result will be Neutral.

Constructors

LevelMatchFilter()

Default constructor

public LevelMatchFilter()

Properties

AcceptOnMatch

Accept when matching LevelToMatch

public bool AcceptOnMatch { get; set; }

Property Value

bool

Remarks

The AcceptOnMatch property is a flag that determines the behavior when a matching Level is found. If the flag is set to true then the filter will Accept the logging event, otherwise it will Deny the event.

The default is true i.e. to Accept the event.

LevelToMatch

The Level that the filter will match

public Level LevelToMatch { get; set; }

Property Value

Level

Remarks

The level that this filter will attempt to match against the LoggingEvent level. If a match is found then the result depends on the value of AcceptOnMatch.

Methods

Decide(LoggingEvent)

Tests if the Level of the logging event matches that of the filter

public override FilterDecision Decide(LoggingEvent loggingEvent)

Parameters

loggingEvent LoggingEvent

the event to filter

Returns

FilterDecision

see remarks

Remarks

If the Level of the event matches the level of the filter then the result of the function depends on the value of AcceptOnMatch. If it is true then the function will return Accept, it it is false then it will return Deny. If the Level does not match then the result will be Neutral.