Capture debug output in C#

偶尔善良 提交于 2019-12-10 13:48:08

问题


Is it possible to capture debug output (create debug listener) in C#?

I'd like to have functionality like DebugView has, but I'd like to log debug output to SQL Server. Or maybe a better way would be to make DebugView log to a file, and then feed the file to SQL Server?

I've implemented TraceListener and added it to Debug.Listeners collection, but it seems to capture debug only from my application. What I want to do is to capture debug from all applications. Is there a way to do that?


回答1:


DbMon.NET - A simple .NET OutputDebugString capturer at http://www.codeproject.com/KB/trace/DbMonNET.aspx seems to do what you want.




回答2:


Unless you truly have a specific need to roll your own logger, I would use an existing logging framework such as log4net. It has an ADO.NET appender that you can configure to log debug or trace output directly to SQL Server.



来源:https://stackoverflow.com/questions/2809064/capture-debug-output-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!