Table of Contents

Class LevelRangeFilter

Namespace
log4net.Filter
Assembly
log4net.dll

This is a simple filter based on Level matching.

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

Remarks

The filter admits three options LevelMin and LevelMax that determine the range of priorities that are matched, and AcceptOnMatch. If there is a match between the range of priorities 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 there is no match, Deny is returned.

Constructors

LevelRangeFilter()

Default constructor

public LevelRangeFilter()

Properties

AcceptOnMatch

Accept when matching LevelMin and LevelMax

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 Neutral the event.

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

LevelMax

Sets the maximum matched Level

public Level LevelMax { get; set; }

Property Value

Level

Remarks

The maximum 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.

LevelMin

Set the minimum matched Level

public Level LevelMin { get; set; }

Property Value

Level

Remarks

The minimum 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)

Check if the event should be logged.

public override FilterDecision Decide(LoggingEvent loggingEvent)

Parameters

loggingEvent LoggingEvent

the logging event to check

Returns

FilterDecision

see remarks

Remarks

If the Level of the logging event is outside the range matched by this filter then Deny is returned. If the Level is matched then the value of AcceptOnMatch is checked. If it is true then Accept is returned, otherwise Neutral is returned.