I've never been good at translating filter requirements into xml ;-/
Here's a small filter class that only accepts Debug, Warn, and Fatal
messages:
public class AcceptDebugWarnFatalFilter : FilterSkeleton
{
public override FilterDecision Decide(LoggingEvent loggingEvent)
{
Level level = loggingEvent.Level;
if (Level.Compare(level, Level.Debug) == 0 ||
Level.Compare(level, Level.Warn) == 0 ||
Level.Compare(level, Level.Fatal) == 0)
{
return FilterDecision.Accept;
}
else
{
return FilterDecision.Deny;
}
}
}
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="Log.txt" />
<layout type="log4net.Layout.PatternLayout" />
<filter type="Company.Logging.AcceptDebugWarnFatalFilter" />
</appender>
--- Meera Rajaram <[EMAIL PROTECTED]> wrote:
> Is it possible to explicitly turn logging on for Debug, Warn and
> Fatal
> messages. In other words only the specified log levels should be
> recorded and no other messages like Info and Error should be
> recorded?
> Currently in the log4Net examples it allows to specify just one
> loglevel
> (ie either debug, Warn, etc or All) - but is there some way to just
> turn
> on logging only for specific levels and ignore the remaining ones?
>
>
>
> Thanks,
>
> Meera.
>
>