logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Chained loggers
Date Wed, 01 Oct 2008 21:47:04 GMT
When the xml config file is being parsed the nodes in the config file are matched to properties
on the appender. When multiple properties need to be set log4net looks for a method beginning
with the word "Add". Most (all?) the appenders in log4net extend AppenderSkeleton. AppenderSkeleton
has an AddFilter method which is how multiple filters can be added to an appender via the
config file:

 <appender name="FileAppender" type="log4net.Appender.FileAppender">
  <file value="log.txt" />
  <!-- AppenderSkeleton.AddFilter is called for each filter node -->
  <filter>
   <filter type="Company.Logging.CustomFilter1" />
   <filter type="Company.Logging.CustomFilter2" />
   <filter type="log4net.Filter.DenyAllFilter" />
  </filter>
 </appender>

This blog post might be helpful to you:

 http://weblogs.asp.net/tgraham/archive/2007/03/15/a-realistic-log4net-config.aspx



----- Original Message ----
From: Daniel Bigham <dbigham@navtechinc.com>
To: log4net-user@logging.apache.org
Sent: Wednesday, October 1, 2008 5:27:03 PM
Subject: Chained loggers

Hi,

I'm trying to create a chained logger according to the following logic:

if ( condition1 == true && condition2 == true )
{
accept
}

How can this be specified in XML?

Here is what I have tried:

<appender name="SupportToolAppender"
             type="log4net.Appender.AdoNetAppender">
     <filter type="log4net.Filter.PropertyFilter">
       <acceptOnMatch value="false" />
       <key value="eventid" />
       <regexToMatch value="\d+" />
       <next type="log4net.Filter.LevelRangeFilter">                  
<acceptOnMatch value="true" />
         <levelMin value="INFO" />
         <levelMax value="FATAL" />
       </next>
     </filter>
     <filter type="log4net.Filter.DenyAllFilter" />
     ...
</appender>

I guess more specifically my question is how the "next" property can be 
used to define the next logger in the chain. The above doesn't seem to 
work. I've tried some other things such as:

<next>
<filter ...>
   ...
</filter>
</next>

... but that doesn't work either.

I don't see any documentation on the log4net site that explains how this 
is to be done, and Googling it hasn't helped much either.

Thanks,
Daniel

-- 
Daniel Bigham
Software Developer

Navtech, Inc.
295 Hagey Blvd., Suite 200
Waterloo, Ontario, N2L 6R5
tel: (519) 747 1170 x.301
fax: (519) 747-1003
dbigham@navtechinc.com

-- 
Daniel Bigham
Software Developer

Navtech, Inc.
295 Hagey Blvd., Suite 200
Waterloo, Ontario, N2L 6R5
tel: (519) 747 1170 x.301
fax: (519) 747-1003
dbigham@navtechinc.com

Mime
View raw message