Log4net Adonet Appender:运行应用程序的多个实例时数据变得混乱
场景:一个asp.net Web应用程序部署在远程IIS上,并配置为登录到oracle数据库。日志表有这些列:Login_ID、Log_message、Querystring、ipaddress。因此,使用不同的 login_ids 从不同的系统浏览部署的 url
问题:当应用程序在具有不同登录 ID 和不同流程的不同系统上运行时,一个流程/系统的登录 ID 会插入到另一个流程/系统。但是,当运行应用程序的单个实例时,值会被正确插入。
示例:登录 ID X 的用户通过流程“A”浏览网站,而另一个登录 ID Y 的用户则通过流程“B”浏览网站。 Loginid“X”正在插入流“B”和流“A”的记录中
代码:
user = (User)Session["User"];
log4net.GlobalContext.Properties["LOGIN_ID"] = user.loginid;
研究:浏览了几个站点后,我了解到 log4net 上下文无法在 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
这些链接建议我使用httpcontext,我尝试过但无法得到结果。那么任何人都可以帮助我解决这个问题。
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在此处查看我对另一个问题的回答。
我的答案中的最后一个建议可能是最容易实现的,并且它可能正是您想要的。我的建议直接基于您上面引用的相同链接。
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.