Solved

How to redirect stdout / stderr in a windows service

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

24 Experts available now in Live!

Get 1:1 Help Now