使用 Enterprise Library 5 进行数据库日志记录
有人知道如何使用 EL 5.0 实现数据库异常日志记录吗?
谢谢!
Anybody knows how to implement database exception logging using EL 5.0?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将需要针对数据库运行脚本,以便它为您创建特定的表结构。此外,还将创建一个存储过程,您必须在跟踪侦听器的配置部分中引用该存储过程。您应该能够在此处找到此脚本文件:C:\EntLib41Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts 文件夹。我知道这是该库的版本 4,但查看版本 5,我意识到文件夹结构发生了变化,并且脚本文件夹已经不见了。但是,此网站此处应该为您提供一些指导。
您也可以尝试 MSDN 文档
我对 EntLib50Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts 文件夹的神秘消失做了更多调查。结果是,如果您像我一样使用 MSI 将 Entlib5 安装到计算机上。实际上有一个可以运行的源代码 MSI,如果您使用的是 64 位电脑或 C:\Program Files\Microsoft Enterprise Library 5.0,则它深埋在 C:\Program Files (x86)\Microsoft Enterprise Library 5.0\src 中\src 如果你不是。运行此 MSI,它将安装 Entlib5 的源代码以及缺少的 Scripts 文件夹。
You will need to run a script against the database so that it creates a specific table structure for you. Also, there will be a stored procedure that will be created that you will have to reference in the Trace Listener's configuration section. You should be able to find this script file here: C:\EntLib41Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts folder. I know this is for version 4 of the library, but looking into the version 5, I realized that the folder structure has taken a change and the script folder is no where in sight. However, this site here should provide you with some guidance.
You may also try MSDN Documentation
So I did a little bit more investigation into the mysterious disappearance of the EntLib50Src\Blocks\Logging\Src\DatabaseTraceListener\Scripts folder. What it turn out to be is that if you had install the Entlib5 to your computer using the MSI like I did. There is actually a Source Code MSI that you can run, buried deep in the C:\Program Files (x86)\Microsoft Enterprise Library 5.0\src if you're using a 64bit pc or C:\Program Files\Microsoft Enterprise Library 5.0\src if you're not. Run this MSI and it will install the the source codes for Entlib5 and also the missing Scripts folder.
您已经完成了动手教程吗?他们有一个专门针对企业库的每个功能的部分,包括异常日志记录。 http://www.microsoft.com/download/en /details.aspx?displaylang=en&id=6932
Have you walked through the hands on tutorial? They have a section dedicated to each feature of the enterprise library, including exception logging. http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=6932
第一步:配置日志块以记录到数据库。有一个实验室可以做这件事。
第二步:配置异常块以记录异常。有一个实验室可以做这件事。
第三步:将异常块指向写入数据库的日志类别。
就是这样。将异常记录到数据库没有什么特别的。异常块将写入日志块。日志记录块对待这些就像对待任何其他日志操作一样。按照设置数据库日志记录的说明进行操作,您就基本上完成了。
Step one: configure the logging block to log to the database. There's a lab for that.
Step two: Configure the exception block to log exceptions. There's a lab for that.
Step three: Point the exception block at the logging category that writes to the database.
That's it. There's nothing special about logging exceptions to the database. The exception block will write to the logging block. The logging block treats these just like it would any other logging operation. Follow the instructions for setting up database logging and you're basically done.