Friday, May 18, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Chained loggers
Prev Next
You are not authorized to post a reply.

Author Messages
Daniel Bigham

10/01/2008 11:27 PM  

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

Ron Grabowski

10/01/2008 11:47 PM  

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

Daniel Bigham

10/02/2008 3:42 PM  

Thanks for your reply Ron.

I tried structuring my filters as you suggest, but the behavior is:

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


What I'm looking for is:

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


I also took a look at the blog post you mentioned and again the behavior
suggested is:

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


Thanks,
Daniel

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Chained loggers



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement