Debug.WriteLine 在 Windows 服务到 OutputDebugString
Debug.WriteLine in Windows Service to OutputDebugString
上下文
注意:log4net 从问题中分离出来,只是写下更多诊断事实的上下文
我正在使用 log4net RollingFileAppender 和 DebugAppener。该应用程序可以在控制台模式下启动,但也可以作为服务安装。当启动 stanalone 时,所有 DebugAppener 都会转到通过 Mark Russinovich 的 DebugView 确认的 OutputDebugString。
当 运行 作为服务时,仅写入文件日志,不输出 OutputDebugString。
诊断
- 问题与 log4net 或 DebugAppender 无关。完全一样
问题发生在纯 Debug.WriteLine("Hello world") 调用
- 该服务 运行 作为 LocalSystem(因此可能不是权限问题)
- 两种情况都正确写入文件
问题
我错过了什么?当 运行 作为服务时,如何写入 OutputDebugString(使用 log4net DebugAppender)?
两种可能的情况是
- 确保 DebugView 是 运行 管理员
- 勾选 "Capture" 菜单中 "Capture global Win32" 处的复选标记
它还应该显示服务的调试消息。
上下文
注意:log4net 从问题中分离出来,只是写下更多诊断事实的上下文
我正在使用 log4net RollingFileAppender 和 DebugAppener。该应用程序可以在控制台模式下启动,但也可以作为服务安装。当启动 stanalone 时,所有 DebugAppener 都会转到通过 Mark Russinovich 的 DebugView 确认的 OutputDebugString。 当 运行 作为服务时,仅写入文件日志,不输出 OutputDebugString。
诊断
- 问题与 log4net 或 DebugAppender 无关。完全一样 问题发生在纯 Debug.WriteLine("Hello world") 调用
- 该服务 运行 作为 LocalSystem(因此可能不是权限问题)
- 两种情况都正确写入文件
问题
我错过了什么?当 运行 作为服务时,如何写入 OutputDebugString(使用 log4net DebugAppender)?
两种可能的情况是
- 确保 DebugView 是 运行 管理员
- 勾选 "Capture" 菜单中 "Capture global Win32" 处的复选标记
它还应该显示服务的调试消息。