Global.asax 和日志记录
每次向应用程序发出请求时,我都可以利用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
大多数时候,您可以在 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
有更好的方法可以做到这一点,但可以在 Begin_Request 中调用您想要的任何内容。
具体来说:
There are better ways to do it, but call whatever you want in Begin_Request.
Specifically:
我认为您需要调查 HttpModules (2) (3)。
I think you need to investigate HttpModules (2) (3).