g.pickardou g.pickardou - 3 years ago 136
C# Question

Debug.WriteLine in Windows Service to OutputDebugString


NOTE: log4net isolated out from the issue, just writing the context for more diagnostic facts

I am using log4net RollingFileAppender and DebugAppener. The app can be started in console mode but also can be installed as service. When starting stanalone all DebugAppener goes to OutputDebugString confirmed via Mark Russinovich's DebugView.
When running as a service only the file log is written no output OutputDebugString.


  • The issue is not related with log4net or DebugAppender. The very same
    issue happens with a pure Debug.WriteLine("Hello world") call

  • The service is running as LocalSystem (so probably it is not a permission issue)

  • File is written correctly both cases


What am I missing? How can I write to OutputDebugString (using log4net DebugAppender) when running as a service?

Answer Source

The two likely cases are

  • make sure DebugView is run as Administrator
  • check the checkmark at "Capture global Win32" in the "Capture" menu

and it should display debug messages of services as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download