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
Diagnostic logging is a troubleshooting mode. When diagnostic logging is enabled, Google Ads Editor automatically saves reports containing messages sent between Google Ads Editor and the Google Ads server.
Each file is written by a separate logger, so you need to use both inside of your code: ILog Log = LogManager. GetLogger(typeof(LogTest)); ILog ErrorLog = LogManager. GetLogger("error"); Log.Info("Debug message"); ErrorLog.
Logging levels are used to filter logging output, tailoring the amount of data output to the situation in hand. Each logging level is associated with the type of data logged. DEBUG, INFO, and TRACE events are typically non-error conditions that report on the behavior of an application.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With