write to IIS log from an ASP.NET application(从 ASP.NET 应用程序写入 IIS 日志)
问题描述
我想让我的 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 日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 ASP.NET 应用程序写入 IIS 日志


- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01