how can I enable database logging in my ASP.net application?
如何在ASP.net应用程序中启用数据库日志记录?
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).
我正在使用VS2010 (ASP.net MVC2项目),我希望看到日志记录能够突出显示应用程序和数据库之间的数据库活动,包括数据库连接的建立(因为我确实在某个地方出现了与连接相关的错误)。
I'm using SqlServer Express 2008.
我正在使用SqlServer Express 2008。
thanks
谢谢
1 个解决方案
#1
3
I think what your asking for is to enable and setup database auditing in SQL Server 2008.
我认为您的要求是在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.
遗憾的是,我认为它在SQL Server Express edition中不可用,但您可以尝试一下。
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.
否则它就是一个定制的解决方案。基本上,将SQL查询或SQL链接或实体链接打包,以记录正在发生的事情。但是,如果您已经有了连接问题,这可能不会帮助您找到问题所在。
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.
在触发器的旁边,可以保存最后修改的并为用户和时间创建的戳记。
#1
3
I think what your asking for is to enable and setup database auditing in SQL Server 2008.
我认为您的要求是在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.
遗憾的是,我认为它在SQL Server Express edition中不可用,但您可以尝试一下。
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.
否则它就是一个定制的解决方案。基本上,将SQL查询或SQL链接或实体链接打包,以记录正在发生的事情。但是,如果您已经有了连接问题,这可能不会帮助您找到问题所在。
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.
在触发器的旁边,可以保存最后修改的并为用户和时间创建的戳记。