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 Tue, 06 Dec 2005 08:02:31 GMT

Yes that sounds correct, is there no way of doing this with existing
filters? At the moment I define a root and class specific logger then I
can filter using:

<filter type="log4net.Filter.LoggerMatchFilter">
    <loggerToMatch value="All.Messages.Classname"/>
</filter>
<filter type="log4net.Filter.LevelRangeFilter">
    <levelMin value="WARN" />
</filter>

This gives me some OR logic as the LoggerMatchFilter will pass unmatched
messages to the LevelRangeFilter. I'd like to avoid having to define the
second logger and be able to use something like:

<filter type="log4net.Filter.ClassMatchFilter">
    <classToMatch value="All.Messages.Classname"/>
</filter>
<filter type="log4net.Filter.LevelRangeFilter">
    <levelMin value="WARN" />
</filter>

Is this sort of thing possible in a filter? If so I might have a go at
writing one.

Thanks
Barney


> -----Original Message-----
> From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
> Sent: Tuesday 06 December 2005 04:24
> To: Log4NET User
> Subject: Re: filtering on message source
> 
> 
> 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" <Barnaby.Dalton@brevanhoward.com> 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
> > 
> > 
> > 
> 

Mime
View raw message