Solved

How to redirect stdout / stderr in a windows service

Posted on 2008-09-29
2
1,642 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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
Adding queries and macros to many Microsoft Access Databases. 7 75
Get id from json Data with NewtonSoft 3 35
Runtime Error 2 29
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:…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now