logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Prouse <Rob.Pro...@Ivara.com>
Subject RE: Custom Properties in an ASP.Net Web Application
Date Wed, 01 Sep 2010 15:59:18 GMT
For the common log appenders, the log is output synchronously with the log message, so it should
be on the same thread, so it shouldn't be a problem. I am not sure of the behavior when you
use an asynchronous appender (like the ADO appender), but it should be pulling the context
out before it goes asynchronous. If it doesn't, then that would be a bug in log4net, but I
would need to look at the code.

What appender are you using?

From: Gagne, Chris [mailto:cgagne@ivey.uwo.ca]
Sent: Wednesday, September 01, 2010 11:03 AM
To: Log4NET User
Subject: Custom Properties in an ASP.Net Web Application

Here's our situation...

We're adding debug messages to an ASP.Net web application that allows our users to apply for
a job online.  We have a custom properties and database fields created named JobPostingId
and MemberId.  Here's a small code snippet of our logging.

ILog logger = LogManager.GetLogger(CONST_JOBPOSTINGS);

if (logger.IsDebugEnabled)
                log4net.ThreadContext.Properties[CONST_JOBPOSTINGID] = JobPostingId;
log4net.ThreadContext.Properties[CONST_MEMBERID] = MemberId;

We've noticed very inconsistent values for our custom properties.  I suspect it has something
to do with the context belonging to a thread and that same thread being reused by different
web requests, therefore different users.

Does anyone have suggestions for me on how I can capture user specific data into custom properties?
 Any thoughts or suggestions would be greatly appreciated.

View raw message