Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to redirect stdout / stderr in a windows service

Posted on 2008-09-29
2
Medium Priority
?
1,770 Views
Last Modified: 2013-12-17
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#?
0
Comment
Question by:swsbuyer
2 Comments
 
LVL 6

Expert Comment

by:wwnosal
ID: 22600809
Call your program like this:

myProg.exe > myLog.log
0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 2000 total points
ID: 22600976
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

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Integration Management Part 2
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question