Skip to content

Instantly share code, notes, and snippets.

@ramonsmits
Forked from lkaczanowski/ILogExtensions.cs
Last active February 18, 2016 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramonsmits/c864536b038acb6ace77 to your computer and use it in GitHub Desktop.
Save ramonsmits/c864536b038acb6ace77 to your computer and use it in GitHub Desktop.
ILog extension for TRACE and VERBOSE log4net levels
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