问题描述
我想让我的 ASP.NET 应用程序在某处将行写入日志.IIS 是否提供任何内置方式来记录 ASP.NET 日志消息?我在想可能有一种方法可以捕获对 System.Diagnostics.Debug.WriteLine() 的调用,但我找不到任何方法.
I want to have my ASP.NET application write lines to a log somewhere. Does IIS provide any built-in way to log ASP.NET log messages? I was thinking there might be a way to capture calls to System.Diagnostics.Debug.WriteLine(), but I can't find any way to do it.
推荐答案
要捕获 Debug.Write
和 Debug.WriteLine
使用 DebugView 来自 sysinternals.
To capture the Debug.Write
and Debug.WriteLine
use the DebugView from sysinternals.
http://technet.microsoft.com/en-us/sysinternals/bb896647
当然你必须用 Debug=true
编译,否则函数根本不会被调用.因此,Debug.Write 是一种仅用于实时测试和调试您的应用程序的好方法,而不是一般记录错误的解决方案.对于您希望保存错误的情况,我认为您需要使用其他用户建议的一个库,或者直接在事件查看器上写下您的错误.
Of course you have to compile with Debug=true
or else the functions is not called at all. So the Debug.Write is a good way only for test in real time and debug your application and not a solution to keep log on the errors in general. For the case that you like to save the errors I think that you need to ether use one library of the other user suggestions, or write direct on event viewer your errors.
ps:由于某种原因,4.78 版无法在我的 windows xp 上运行,我切换回 4.77
这篇关于从 ASP.NET 应用程序写入 IIS 日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!