I recently wrote a simple windows service that hosted batch files and other applications within a service process. I found some great stuff located here, which really helped me along. Like many other developers, I quickly discovered that debugging and diagnosing issues wasn't particularily easy. On my machine, it was fairly simple to set a break point and manually attach to the service, but diagnosing issues on other machines lacked detail in the Event Log. What I needed was a way to capture the output of my hosted application. As I was already using log4net to trace through application flow, I used the following approach to redirect the output of my hosted application into my logger. using System.Diagnostics; using log4net;
public class MyService : ServiceBase { private static readonly ILog log = LogManager.GetLogger(typeof(MyService));
private Process process;
public override void OnStart(string[] args) { process = new Process();
"Redirect Standard Output of a Service to log4net"
No comments yet. -