We have a C# service that is deployed to a remote customer system. The application writes a substantial amount of \"diagnostic\" information to the console (i.e. Console.WriteL
Here is how I viewed the console output of a service running under Windows 7. This might help if you are absolutely unable to modify the source code of the service to log to a file.
Run services.msc and edit the properties of the service. On the "Log On" tab, check the "Allow service to interact with desktop"
Use registry editor to modify the ImagePath of your service: Go to HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\ [your service name] and edit ImagePath. Append cmd.exe /c
to the beginning of the ImagePath string. So if your original ImagePath is c:\myService\myservice.exe
your new ImagePath should be cmd.exe /c c:\myService\myservice.exe
.
Start your service. You should get a popup window titled "Interactive Services Detection". Select "View the message". Your screen should switch contexts and display the console window. When finished, click the "Return now" button.
When finished debugging, modify ImagePath back to its original value. Then uncheck the "Allow service to interact with desktop" checkbox in the service properties and restart your service.
Warning: I've only done this with one service and it worked for me. I do not know if it will work for any service or if it will cause any unexpected results so I strongly suggest you only do this in a non-production environment.