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;
 }
}

--- Ron Grabowski <[EMAIL PROTECTED]> wrote:

> It sounds like you need to write a custom filter that looks like
> this:
> 
>  <filter type="Company.Project.Logging.CustomFilter">
>   <logLevelEqualOrAbove level="WARN" />
>   <allMessagesFromLogger name="Company.Project.UI.Login" />
>   <allMessagesFromLogger name="Company.Project.UI.Logout" />
>  </filter>
> 
> That would accept all messages from Login and Logout and only those
> messages from other loggers that are WARN or above.
> 
> Is that correct?
> 
> --- "Dalton, Barnaby" <[EMAIL PROTECTED]> wrote:
> 
> > 
> > I need to combine messages from one class with messages of level
> WARN
> > or
> > above from other classes. I can easily log the WARN and above
> > messages
> > but was wondering on the best way to add in ALL messages from the
> > specific class. Is the best technique to define a second logger and
> > then
> > use LoggerMatchFilter in the appender? Can I avoid having to define
> a
> > second logger and use some kind of ClassSource filter?
> > 
> > Thanks
> > Barney
> > 
> > 
> > 
> 
> 

Reply via email to