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/sy开发者_如何学编程stem. But when a single instance of the application is runned, walues are properly inserted.
Example: With login id X, the site is browsed through a flow ‘A’ and another user with loginid Y is browsing the site 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
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.
Check my answer for another question here.
The last suggestion in my answer might be the easiest to get working and it might do just what you want. My suggestion is based directly on the same links that you reference above.
精彩评论