How to redirect stdout / stderr in a windows service

I have an existing application that needs to be run as a service. The application dumps some output on the console. I would like to redirect the output to a log file. Any idea how to do this in C#?
swsbuyerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
gregoryyoungConnect With a Mentor Commented:
Using C# you can do this with the process object. You can run the process and redirect it's standard error/output to a stream. You can then do whatever you want with the output.

http://www.codeproject.com/KB/cs/ProcessStartDemo.aspx

and yes you can do this within a windows service.

Cheers,

Greg
0
 
wwnosalCommented:
Call your program like this:

myProg.exe > myLog.log
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.