语境
注意: log4net 与问题无关,只需编写上下文以获取更多诊断事实
我正在使用 log4net RollingFileAppender 和 DebugAppener。该应用程序可以在控制台模式下启动,也可以作为服务安装。启动 stanalone 时,所有 DebugAppener 都会转到通过 Mark Russinovich 的 DebugView 确认的 OutputDebugString。当作为服务运行时,只写入文件日志,没有输出OutputDebugString。
诊断
- 该问题与 log4net 或 DebugAppender 无关。纯 Debug.WriteLine("Hello world") 调用也会出现同样的问题
- 该服务作为 LocalSystem 运行(因此可能不是权限问题)
- 两种情况下文件都正确写入
问题
我错过了什么?作为服务运行时,如何写入 OutputDebugString(使用 log4net DebugAppender)?