Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   Bind Console & log file (http://www.programmingforums.org/showthread.php?t=12416)

Booooze Jan 21st, 2007 7:11 PM

Bind Console & log file
 
Hey Guys.

Just curious as it might save me some time. Does anyone know if there is a way (already built into the framework) to have everything that shows up in the console(System.Console) window be written to a text/log file? I'm looking for an easy way to bind it.

Thanks.

Dameon Jan 21st, 2007 8:04 PM

If you want to do some fancy tricks such as having output appear in the console AND in the log...
http://msdn2.microsoft.com/en-us/lib...le.setout.aspx

Otherwise, it would be just as effective to use program.exe > file to redirect standard output via your command shell.

lectricpharaoh Jan 22nd, 2007 3:24 AM

If you wish to display the output in the console window and redirect it to a file, you can take Dameon's suggestion a step further. Derive a new class from TextWriter or StreamWriter that has two private StreamWriter members (one of which is connected to the console, and the other to your file) and for the Write() method, provide an implementation that writes to both streams.

Booooze Jan 22nd, 2007 8:38 PM

Daemon I took a quick look at what you said and it seems to be working. I'm going out look into it more and post back. Just have to find the time. Thanks for the replies guys.


All times are GMT -5. The time now is 1:43 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC