Monday, May 21, 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: Using thread context data from a filter to decide whether to append...
Prev Next
You are not authorized to post a reply.

Author Messages
Matt Lund

06/11/2009 7:15 PM  

Hi all.  I’d like to know if I’m doing this correctly.  I want to set a value in ThreadContext.Properties from application code.  I then want some appenders to log or not log based on this contextual information.  I believe the right way to do this is to create a class that implements IFilter and apply some filters to the these appenders.

 

So far I’ve created my filter class, and I’ve added the ThreadContext.Properties[“foo”] = “bar” to my application code.

 

Now, I’m looking at how to implement the Decide method on my filter class.  I had assumed that the “foo”-“bar” information would be available in the LoggingEvent that gets passed in to Decide but if it’s there, I don’t see it.  However, if I directly access ThreadContext.Properties[“foo”] from inside the Decide method then that works.  This seemed odd to me at first because I didn’t know that Decide() would always be called on the thread where the log.Info(“etc”) call came from.  But if Decide() is always called on that thread, I should be safe to access ThreadContext.Properties[“foo”] from inside Decide() – right?

 

If I’m not correct or there’s a better way to access the thread-contextual information from inside Decide() please let me know…

 

Matt Lund

06/15/2009 4:48 PM  

Bump J  Hoping for some feedback…

 

 

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Using thread context data from a filter to decide whether to append...



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