如何在 ASP.net 应用程序中启用数据库日志记录

发布于 2024-09-03 03:16:57 字数 185 浏览 2 评论 0原文

如何在 ASP.net 应用程序中启用数据库日志记录?

我正在使用 VS2010(ASP.net MVC2 项目),并且希望查看突出显示应用程序和数据库之间的数据库活动的日志记录,包括数据库连接建立(因为我确实在某处出现了与连接相关的错误)。

我正在使用 SqlServer Express 2008。

谢谢

how can I enable database logging in my ASP.net application?

I am using VS2010 (ASP.net MVC2 Project) and would like to see logging that highlights database activity between the application and the database, including database connection establishment (as I do have a connection related error somewhere).

I'm using SqlServer Express 2008.

thanks

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

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

发布评论

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

评论(1

陈年往事 2024-09-10 03:16:57

我认为您要求的是在 SQL Server 2008 中启用和设置数据库审核

。 ">http://www.sql-server-performance.com/articles/dba/Database_Audit_Specifications_in_SQL_Server_2008_p1.aspx

遗憾的是,我认为它在 SQL Server Express 版本中不可用,但您可以尝试一下。

但是,如果它在 Express 版本中不起作用。您可以从服务器跟踪记录活动。使用分析器并将分析的数据推送到表或文件。注意:这是一个昂贵的解决方案(可能会出现一些性能问题,但有时在确定特定错误(包括连接问题)时很有用。)

否则它是一个自定义解决方案。基本上将您的 SQL 查询或链接到 SQL 或链接到实体包装在将记录正在发生的情况的内容中。但如果您已经遇到连接问题,这可能无助于找到问题。

或者在表上触发,记录谁做了这件事以及做了什么。这不会直接告诉您是否存在连接问题,但如果您期望插入、更新或删除数据,那么您将有一个日志。

在触发器的旁注中,您始终可以存储用户和时间的最后修改和创建的标记。

I think what your asking for is to enable and setup database auditing in SQL Server 2008.

http://www.sql-server-performance.com/articles/dba/Database_Audit_Specifications_in_SQL_Server_2008_p1.aspx

Sadly I do not think it is available in SQL Server Express Editions but you could try.

However if it does not work in express editions. You could log activity from a server trace. using profiler and push the profiled data to a table or file. Note: this is an expensive solution (could have some preformance issues, but is usefule sometimes in determining specific errors, including connectivity issues.)

Otherwise it is a custom solution. Basically wrap your SQL querys or Link to SQL or Link to entities in something that will log what is going on. But if your already having connectivity issues this might not help find the problem.

Or triggers on tables that log who did it and what was done. This wont directly tell you if your having connectivity issues, but if your expecting data to be inserted, updated, or deleted then you will have a log of it.

On a side note to triggers you could always store the last modified and created stamps for user and time.

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