logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dalton, Barnaby" <Barnaby.Dal...@brevanhoward.com>
Subject RE: filtering on message source
Date Thu, 08 Dec 2005 08:06:19 GMT

Thanks,
Do I need to create a logger named Company.Project.UI.Login/Logout or
does logger refer to a classname and will work with only a root logger
defined? 

Barney

> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: Tuesday 06 December 2005 23:51
> To: Log4NET User
> Subject: Re: filtering on message source
> 
> 
> Here's how to use it:
> 
>  <filter type="Company.Project.Logging.CustomFilter">
>   <logLevelEqualOrAbove value="WARN" />
>   <allMessagesFromLogger value="Company.Project.UI.Login" />
>   <allMessagesFromLogger value="Company.Project.UI.Logout" /> 
>  </filter>  <filter type="log4net.Filter.DenyAllFilter" />
> 
> --- Ron Grabowski <rongrabowski@yahoo.com> wrote:
> 
> > public class CustomFilter : FilterSkeleton
> > {
> >  private Level logLevelEqualOrAbove = Level.All;
> >  private Hashtable acceptAllMessagesLookup = new Hashtable();
> > 
> >  public override FilterDecision Decide(LoggingEvent loggingEvent)  {
> >   if (acceptAllMessagesLookup.Contains(loggingEvent.LoggerName))
> >   {
> >    return FilterDecision.Accept;
> >   }
> >   else
> >   {
> >    if (Level.Compare(loggingEvent.Level,LogLevelEqualOrAbove)>=0)
> >    {
> >     return FilterDecision.Accept;
> >    }
> >    else
> >    {
> >     return FilterDecision.Deny;
> >    }
> >   }
> >  }
> > 
> >  public Level LogLevelEqualOrAbove
> >  {
> >   get { return logLevelEqualOrAbove; }
> >   set { logLevelEqualOrAbove = value; }
> >  }
> > 
> >  public void AddAllMessagesFromLogger(string logger)
> >  {
> >   acceptAllMessagesLookup[logger] = null;
> >  }
> > }
> 

Mime
View raw message