Reputation: 9966
I wish to be able to write entries to a console application which will describe when actions have been completed, possibly writing them to a .txt file at one point.
I would like it to be used with a separate GUI application running at the same time so i can use the application and monitor the log simultaneously.
I only assume the Diagnostic class is the right tool to use however I have never used any logging methods before, so i welcome any other suggestions.
Thanks
Upvotes: 5
Views: 16884
Reputation: 233
Here's my admittedly self-serving answer: use my logging framework. Unlike some other logging frameworks, it's extremely easy to use and configure. It also has a very small footprint. In addition, it comes with a small application that you can use to view your logs in real-time. It sounds to me like it's everything you need.
Upvotes: -1
Reputation: 941465
The $0.25 solution is Project + Properties, Application tab, Output type = Console Application. Now you've got a console window as well as your regular UI. Anything you write with Console.WriteLine() will end up on that console window.
Upvotes: 3
Reputation: 300549
Use DebugView from SysInternals to capture debug output. This is a separate GUI application that captures trace /debug output.
This post, Using DebugView and C#, shows an example.
Upvotes: 2
Reputation: 55082
I recommend you start using log4net as soon as possible; it's fairly trivial to use (though setting up is slightly complex, you need to make a few config entries), and it can be quite a beautiful system.
Upvotes: 1
Reputation: 415735
Look at System.Diagnostics.Trace. You can add different TraceListeners to it, including listeners for the Console or files. Then replace all your Console.Write()/Console.WriteLine() calls with Trace.Write()/Trace.WriteLine() and you're good. You can even implement your own TraceListener (it's very easy) to send the messages to your GUI app.
Upvotes: 8