I want to implement some basic tracing in a simple c# (WPF) application that will only be used internally by testers. I basically want the testers to be able to view a log of what they've done and then optionally save it to a file (of their choosing). This would allow the testers to see what they've done thus far in the test and optionally save the log to file for posterity or whatever.
In researching how to implement simple tracing in .Net (using System.Diagnostics.Trace), it seems the default answer is to use log4net (or perhaps NLog, as referenced in Is log4net dead?) instead. My issue with that is that my tracing doesn't need to be fully-featured or anything special, so it seems like overkill to implement an external library (which seems to be backed up by Jeff Atwood himself in a comment in How to save the output of a console application (and others elsewhere, but still...)). If either log4net or NLog is, in fact, the best/only answer (even in my case), I may still accept it (i.e. I'm not entirely closed to the idea of using them, but not terribly excited in it), but try not to harp on (/focus solely on) that one (if possible)...
With that in mind, does anyone have any suggestions on how to implement the listeners such that I can pop open a dialog with the trace log visible (e.g. via a View Log
button) and then optionally save the contents of that dialog (or the trace log itself) to a file (e.g. via a Save Log
button in the `View )?
It seems like it would be relatively simple to implement a listener that simply logs the traces to a collection of some sort in the app, in which case View
simply shows the collection in a listbox or something and Save
just saves that list to file (duh), but then what if the app stays open for a long time and the trace log grows super-large? Perhaps a buffer-type collection that only logs the last x
messages? Suggestions?