[英]Capture debug output in C#
Is it possible to capture debug output (create debug listener) in C#? 是否可以在C#中捕获调试输出(创建调试监听器)?
I'd like to have functionality like DebugView has, but I'd like to log debug output to SQL Server. 我想拥有像DebugView这样的功能,但我想将调试输出记录到SQL Server。 Or maybe a better way would be to make DebugView log to a file, and then feed the file to SQL Server?
或者更好的方法是将DebugView日志记录到文件,然后将文件提供给SQL Server?
I've implemented TraceListener
and added it to Debug.Listeners
collection, but it seems to capture debug only from my application. 我已经实现了
TraceListener
并将其添加到Debug.Listeners
集合中,但它似乎只从我的应用程序捕获调试。 What I want to do is to capture debug from all applications. 我想要做的是从所有应用程序捕获调试。 Is there a way to do that?
有没有办法做到这一点?
DbMon.NET - http://www.codeproject.com/KB/trace/DbMonNET.aspx上的 一个简单的.NET OutputDebugString捕获器似乎可以满足您的需求。
Unless you truly have a specific need to roll your own logger, I would use an existing logging framework such as log4net . 除非您确实需要自己编写记录器,否则我将使用现有的日志记录框架,例如log4net 。 It has an ADO.NET appender that you can configure to log debug or trace output directly to SQL Server.
它有一个ADO.NET appender,您可以将其配置为将调试或跟踪输出直接记录到SQL Server。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.