I have a program which writes debug messages and error codes in the Console. Now I want to add something like a "view console" window which shows the stuff which has been written in thee console. Is there a possibility to read the stuff simply, or should I just create a static class Console and save the debug messages and putting them in the default Console. I don't want to capture any user inputs in the console.
Asked
Active
Viewed 839 times
0
-
I would make a static logging class and store the messages there rather than playing with the actual Console – Sami Kuhmonen May 13 '15 at 15:15
-
You should be using the `Trace` class, not `Debug`. `Debug.Writeline` (or any other `Debug.` are removed when you go into release mode. You can then use trace listeners to watch the output or log it to a file. – Ron Beyer May 13 '15 at 15:17
-
http://nlog-project.org/ https://logging.apache.org/log4net/ – AK_ May 13 '15 at 15:18
-
I am currently using System.Console.WriteLine(...); not Debug.WriteLine – leAthlon May 13 '15 at 15:30
3 Answers
1
There's always the option of a standard logging class. Note also that within System.Console
you can redirect the output stream using Console.SetOut
- this way you can use all the standard Console
methods, but receive them and store them in your own logging class.

David
- 10,458
- 1
- 28
- 40
-
In a project where all the logging is done via the `System.Console`, this is one pretty solution, no need to replace all of your calls :)..... Or i misunderstood – Irwene May 13 '15 at 15:21
-
no, you understood it right, I thought I could be lazy and use System.Console as logging class... – leAthlon May 13 '15 at 15:32
-
Being "lazy" about using a logging class can also be helpful - there's nothing but a small configuration change if you want to have an actual console (I would recommend during debug), you don't need to recreate all of the functionality packaged into Console, and you can ensure any further development has less to reference. – David May 13 '15 at 16:11
0
How do I show a console output/window in a forms application?
This has been asked a few times, this looks like the most useful response.
-
Sorry, this wasn't asked, I've read and used this already in an other project. – leAthlon May 14 '15 at 08:24
0
I'd replace all your Console outputs with some Logger calls.
You can create a basic one which will append each output to a String (that's just an example)
You'll just have to display this String in the "Console" (please notice the quotes :)) Window for our user to be able to see it.

Irwene
- 2,807
- 23
- 48