Log4net Adonet Appender:运行应用程序的多个实例时数据变得混乱

发布于 2024-11-24 20:51:19 字数 941 浏览 3 评论 0原文

场景:一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿得七秒忆 2024-12-01 20:51:19

在此处查看我对另一个问题的回答

我的答案中的最后一个建议可能是最容易实现的,并且它可能正是您想要的。我的建议直接基于您上面引用的相同链接。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文