Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to redirect stdout / stderr in a windows service

Posted on 2008-09-29
2
Medium Priority
?
1,742 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 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