Global.asax 和日志记录

发布于 2024-08-25 17:16:17 字数 73 浏览 7 评论 0原文

每次向应用程序发出请求时,我都可以利用 Global.asax 中的一个事件来在 ADO.NET 中执行一些 SQL 来记录日志吗?

Is there an event that I can tap into in Global.asax to execute some SQL in ADO.NET for logging every time a request is made to the application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

傲娇萝莉攻 2024-09-01 17:16:17

大多数时候,您可以在 IIS 日志中获取有关请求的信息。您可以使用 logparser,它提供类似 SQL 的功能来查询您想要的内容。

要向 IIS 日志添加更多信息,您可以使用 Response.AppendToLog

要捕获应用程序的所有请求,您可以使用 Global.asax 的 Application_BeginRequest 事件

Most of the time you would be able to get the information about the request in the IIS logs. You can use logparser which provides SQL like functionality to query what you want.

To add more information to IIS logs you can use Response.AppendToLog

To capture all request for an App, you can use Application_BeginRequest event of the Global.asax

遇到 2024-09-01 17:16:17

有更好的方法可以做到这一点,但可以在 Begin_Request 中调用您想要的任何内容。

具体来说:

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
         //Do something at the beginning of every request.
    }

There are better ways to do it, but call whatever you want in Begin_Request.

Specifically:

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
         //Do something at the beginning of every request.
    }
乖乖公主 2024-09-01 17:16:17

我认为您需要调查 HttpModules (2) (3)。

I think you need to investigate HttpModules (2) (3).

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