The ASP.Net server executes the same code for different users in different
threads. So each thread has it own username property. Change the username
property in one thread will not affect the name property of another
thread....
 
I have test this in the VS2005 environment, and it works......
 
Zheng

-----Original Message-----
From: Chen, Xuguang [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 20 September 2007 1:11 PM
To: '[email protected]'
Subject: Can I use static logger and ThreadContext.Properties in asp.net
project?




        Dear all: 

           I am trying to write a log wrap class in asp.net project. 
   I want to use a static logger ,such as public static ILog log =
LogManager.GetLogger("XXXX"); 
    Then I want to use log4net.ThreadContext.Properties[Key] to set custom
fields. Such as "username". 
    But now, I am't sure if the log is safe in asp.net model? 
    For example, user A login website and set
log4net.ThreadContext.Properties["username"] = "User A", 
    then user B login website on another pc  and set
log4net.ThreadContext.Properties["username"] = "User B", 
    Now, if user A write a log, what the username is? 

            On my local pc, I run two IE, it seems to be "UserB". In other
word, it was modified by another IE application. 
    According to log4net.ThreadContext document, it should work well. 
    But I am not sure if it caused by VS2005 test envirement.... 
  
    Thanks 

            Napo ,      


Best Regards, 


Reply via email to