You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by rebelrajesh <ad...@gmail.com> on 2011/07/14 13:19:47 UTC

Log4net Adonet Appender: getting data jumbled when multiple instances of an application are runned

Scenario: A asp.net web application was deployed on remote IIS and is
configured to log into oracle database.Log table has these
columns:Login_ID,Log_message,Querystring,ipaddress. So the deployed url was
browsed from different systems using different login_ids
Problem: When the application is runned on different systems with different
login Ids and different flows, login id  of one flow/system is getting
inserted for another flow/system. But when a single instance of the
application is runned, walues are properly inserted.
Example: With login id X, the application is browsed through a flow ‘A’ and
another user with loginid Y  is browsing the application through  flow ‘B’ .
Loginid ‘ X’ is getting inserted into records with flow ‘B’ and flow ‘A’ 
Code: 
user = (User)Session["User"];
log4net.GlobalContext.Properties["LOGIN_ID"] = user.loginid;
Research: After going through few sites, I learnt that log4net contexts
doesn’t function properly with asp.net. 
http://piers7.blogspot.com/2005/12/log4net-context-problems-with-aspnet.html
http://piers7.blogspot.com/2007/07/log4net-in-aspnet-redux-implement.html
http://piers7.blogspot.com/2005/11/threadstatic-callcontext-and_02.html

These links suggest me to use httpcontext, which i tried but unable to get
the result. So can anyone help me to solwe this problem.

Modified Code:
public class loginIdProvider
    {
        public override string ToString()
        {                       
            string temp = (string)(HttpContext.Current.Items["loginID"]);
            return temp;         
        }
    }
loginIdProvider obj = new loginIdProvider();
                        log4net.GlobalContext.Properties["LOGIN_ID"] =
obj.ToString();






-- 
View this message in context: http://old.nabble.com/Log4net-Adonet-Appender%3A-getting-data-jumbled-when-multiple-instances-of-an-application-are-runned-tp32060419p32060419.html
Sent from the Log4net - Users mailing list archive at Nabble.com.