Created
August 20, 2012 09:46
-
-
Save lkaczanowski/3402710 to your computer and use it in GitHub Desktop.
ILog extension for TRACE and VERBOSE log4net levels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ILogExtentions | |
{ | |
private static readonly log4net.ILog log = | |
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
public static void Trace(this ILog log, string message, Exception exception) | |
{ | |
log.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, | |
log4net.Core.Level.Trace, message, exception); | |
} | |
public static void Trace(this ILog log, string message) | |
{ | |
log.Trace(message, null); | |
} | |
public static void Verbose(this ILog log, string message, Exception exception) | |
{ | |
log.Logger.Log(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, | |
log4net.Core.Level.Verbose, message, exception); | |
} | |
public static void Verbose(this ILog log, string message) | |
{ | |
log.Verbose(message, null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Łukasz,
I already figured out how to use the
ILogExtensions
class. The answers to my questions are:namespace
for the extension classHow to use it in the application?
It is necessary to import the
namespace
, in my caselog4net.Ext
. The application code would look like this.Would you know what to set in the config file for
level
to haveverbose
messages and switch offtrace
messages?I tried the following:
But it did not work. Any idea how I can go fix that?
Many thanks,
Konstantin