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.
| 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. |
|
|
|
ActiveForums 3.7
|