Add Trace methods to System.Diagnostics.TraceListner
Posted
by user200295
on Stack Overflow
See other posts from Stack Overflow
or by user200295
Published on 2010-03-19T17:02:16Z
Indexed on
2010/03/19
17:21 UTC
Read the original article
Hit count: 515
I wrote a Log class derived from System.Diagnostics.TraceListener like so
public class Log : TraceListener
This acts as a wrapper to Log4Net and allows people to use System.Diagnostics Tracing like so
Trace.Listeners.Clear();
Trace.Listeners.Add(new Log("MyProgram"));
Trace.TraceInformation("Program Starting");
There is a request to add additional tracing levels then the default Trace ones (Error,Warning,Information)
I want to have this added to the System.Diagnostics.Trace so it can be used like
Trace.TraceVerbose("blah blah");
Trace.TraceAlert("Alert!");
Is there any way I can do this with an extension class? I tried
public static class TraceListenerExtensions
{
public static void TraceVerbose(this Trace trace) {}
}
but nothing is being exposed on the trace instance being passed in :(
© Stack Overflow or respective owner