I prefer to wrap log4net and provide single point of entry for all logging needs.
eg.
My interface will be like this
public interface ICustomLogger : ILog
{
}
My logger class will be something like this.
public class CustomLogger : ICustomLogger
{
private ILog log4netLogger;
public TMALogger(ILog logger)
{
log4netLogger = logger;
}
//Plus all the methods that you would need to implement for ICustomLogger
}
LogManager will be like this.
public class LogManager
{
public static ICustomLogger GetLogger(Type type)
{
ICustomLogger logger = null;
try
{
ILog log4netLogger = log4net.LogManager.GetLogger(type);
CustomLogger customLogger = new CustomLogger(log4netLogger);
logger = customLogger;
}
catch (Exception ex)
{
logger = null;
}
return logger;
}
}
And finally logger will be used in class like
private readonly ICustomLogger _logger = LogManager.GetLogger(typeof(ClassName));
I hope this helps.