На самом деле все довольно просто:
public class Foo : log4net.Core.LogImpl
{
private static readonly Type DeclaringType = typeof (Foo);
public Foo(log4net.Core.ILoggerWrapper loggerWrapper)
: this(loggerWrapper.Logger) {}
public Foo(log4net.Core.ILogger logger)
: base(logger) {}
protected LoggingEvent GetLoggingEvent<T>(Level level, string message, Exception exception = null)
{
var loggingEvent = new LoggingEvent(DeclaringType, this.Logger.Repository, this.Logger.Name, level, message, exception);
loggingEvent.Properties["type"] = typeof (T).FullName;
return loggingEvent;
}
public void Info<T>(string message)
{
if (!this.IsInfoEnabled)
{
return;
}
var loggingEvent = this.GetLoggingEvent<T>(Level.Info, message);
this.Logger.Log(loggingEvent);
}
public void Info<T>(string message, params object[] args)
{
if (!this.IsInfoEnabled)
{
return;
}
message = string.Format(message, args);
var loggingEvent = this.GetLoggingEvent<T>(Level.Info, message);
this.Logger.Log(loggingEvent);
}
}