【问题标题】:Debug.WriteLine in Windows Service to OutputDebugString [duplicate]Windows 服务中的 Debug.WriteLine 到 OutputDebugString [重复]
【发布时间】:2017-07-26 19:23:49
【问题描述】:

上下文

注意:log4net 与问题无关,只是为更多诊断事实编写上下文

我正在使用 log4net RollingFileAppender 和 DebugAppener。该应用程序可以在控制台模式下启动,也可以作为服务安装。启动 stanalone 时,所有 DebugAppener 都会转到通过 Mark Russinovich 的 DebugView 确认的 OutputDebugString。 作为服务运行时,仅写入文件日志,不输出 OutputDebugString。

诊断

  • 该问题与 log4net 或 DebugAppender 相关。一样的 纯 Debug.WriteLine("Hello world") 调用会出现问题
  • 服务作为 LocalSystem 运行(所以可能不是权限问题)
  • 两种情况下文件都正确写入

问题

我错过了什么?作为服务运行时如何写入 OutputDebugString(使用 log4net DebugAppender)?

【问题讨论】:

  • 这确实是个骗子。对不起

标签: c# debugging windows-services outputdebugstring


【解决方案1】:

两种可能的情况是

  • 确保 DebugView 以管理员身份运行
  • 选中“捕获”菜单中“捕获全局 Win32”处的复选标记

它还应该显示服务的调试消息。

【讨论】:

    猜你喜欢
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 2010-12-18
    相关资源
    最近更新 更多