Hi, > I want to use HttpContext to instead of System.thread that's exactly what the code I provided is doing. > I want to modify the source code of log4net. that's possible, but I don't recommend it. I've gone through maintaining my own versions of 2 frameworks for a while - it's a nightmare always merging changes if bugs get fixed or new features are added. A much better way is to create your solution and contribute it to the project. In this particular case feel free to take my code, update it for log4net 1.2.10 and contribute it to the log4net project. I guess a couple of people might be thankful (including myself) > Because mail system blocked .zip file. Would you like change the XXX.zip to > XXX.txt? It's only your own client software blocking the attachment. You can download the attachment e.g. from apache's mailing archives here: http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200709.mbox/browser <http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200709.mbox/browser> cheers, Erich
________________________________ From: Chen, Xuguang [mailto:[EMAIL PROTECTED] Sent: Sun 2007-09-30 03:07 To: 'Log4NET User' Subject: RE: Can I use static logger and ThreadContext.Properties in asp.net project? Hi: zli, Walden H. Leverich, Erich Eichinger: Thanks a lot. I think my question is a very common scenaio . I also read some mails in log4net maillist about ThreadContext.Properties. But I can't get the answer. I want to use HttpContext to instead of System.thread in my project when HttpContext.Current is not null. I want to modify the source code of log4net. Can it work well? Erich: Because mail system blocked .zip file. Would you like change the XXX.zip to XXX.txt? Thank you very much. -----Original Message----- From: Erich Eichinger [mailto:[EMAIL PROTECTED] Sent: 2007?9?27? 1:45 To: Log4NET User Subject: RE: Can I use static logger and ThreadContext.Properties in asp.net project? Hi, as Walden states: most of the time it will work, but there's no guarantee. a few years ago (log4net 1.2.9) I wrote an extension "LogicalWebContext" to workaround this missing feature. Instead of a threadstatic, it stores properties into HttpContext.Items. The extension consists of a HttpModule and a new Appender, "WebContextAwareForwardingAppender". note, that this code has been written for net 1.1 and log4net 1.2.9. I expect that there are some changes necessary to make it run with log4net 1.2.10 and net 2.0 hope this helps, Erich ________________________________ From: Walden H. Leverich [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 25, 2007 9:13 PM To: Log4NET User Subject: RE: Can I use static logger and ThreadContext.Properties in asp.net project? Xuguang, Assuming you're not using async-pages, a single request will be processed by a single thread, so you can set the properties at request-start and read them later in the process w/out concern. However, note I said "single-request." You cannot use the thread context like session state, there is no guarantee that you'll end up on the same thread next time you request a page from the server, and there's no guarantee that a single thread won't handle multiple requests. In fact, I can promise that a single thread will process multiple requests, that's how you get performance. In short, set the properties at the start of the request (in global.asax for example) and you're fine for that request, but not across requests. -Walden -- Walden H Leverich III Tech Software (516) 627-3800 x3051 [EMAIL PROTECTED] http://www.TechSoftInc.com Quiquid latine dictum sit altum viditur. (Whatever is said in Latin seems profound.)
