Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 14-Jul-11 21:07pm
v2

1 solution

I'm afraid I can't give you a great solution, but at least a servicable one will hopefully do. Here is a post with the answer on how to modify the HttpContext to do your bidding: http://stackoverflow.com/questions/1066062/log4net-threadcontext-and-global-asax[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900