I wrote a Log class derived from System.Diagnostics.TraceListener like so
public class Log : TraceListener
This acts as a wrapper to Log4Net an
Your problem is that you cannot add extension methods to act on static classes. The first parameter of an extension method is the instance that it should operate on. Since the Trace
class is static, there is no such instance. You are probably better off creating your own static log wrapper, exposing the methods you want to have, such as TraceVerbose
:
public static class LogWrapper
{
public static void TraceVerbose(string traceMessage)
{
Trace.WriteLine("VERBOSE: " + traceMessage);
}
// ...and so on...
}
This will also decouple you logging code from the actual logging framework in use, so that you can later switch from trace logging to using log4net or something else, should you wish to.