Add Trace methods to System.Diagnostics.TraceListner
- by user200295
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 :(