-
-
Save ramonsmits/c864536b038acb6ace77 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
using System; | |
using System.Globalization; | |
using log4net.Util; | |
namespace log4net | |
{ | |
public static class LogExtentions | |
{ | |
private static readonly Type ThisDeclaringType = typeof(LogExtentions); | |
public static void Trace(this ILog log, string message, Exception exception) | |
{ | |
log.Logger.Log( | |
ThisDeclaringType, | |
Core.Level.Trace, | |
message, exception | |
); | |
} | |
public static void Trace(this ILog log, string message) | |
{ | |
log.Trace(message, null); | |
} | |
public static void TraceFormat(this ILog log, string format, params object[] args) | |
{ | |
log.Logger.Log( | |
ThisDeclaringType, | |
Core.Level.Trace, | |
new SystemStringFormat(CultureInfo.InvariantCulture, format, args), | |
null | |
); | |
} | |
public static void Verbose(this ILog log, string message, Exception exception) | |
{ | |
log.Logger.Log( | |
ThisDeclaringType, | |
Core.Level.Verbose, | |
message, exception | |
); | |
} | |
public static void Verbose(this ILog log, string message) | |
{ | |
log.Verbose(message, null); | |
} | |
public static void VerboseFormat(this ILog log, string format, params object[] args) | |
{ | |
log.Logger.Log( | |
ThisDeclaringType, | |
Core.Level.Verbose, | |
new SystemStringFormat(CultureInfo.InvariantCulture, format, args), | |
null | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment