Use:
Code: Select all
// Setup inetlab to use log4net by using an adapter
Inetlab.SMPP.Logging.LogManager.SetLoggerFactory(loggerName => new Log4NetToInetLabLoggingAdapter(log4net.LogManager.GetLogger(loggerName)));
Code: Select all
/// <summary>
/// Enables InetLab framework to use
/// </summary>
public class Log4NetToInetLabLoggingAdapter : Inetlab.SMPP.Logging.ILog
{
private readonly ILog _log;
public Log4NetToInetLabLoggingAdapter(log4net.ILog log4netLogger)
{
_log = log4netLogger;
}
public void Error(object message, Exception ex)
{
_log.Error(message, ex);
}
public void Error(object message)
{
_log.Error(message);
}
public void Warn(object message, Exception ex)
{
_log.Warn(message, ex);
}
public void Warn(object message)
{
_log.Warn(message);
}
public void Info(object message)
{
// Ignore info logging from smtp
}
public void Debug(object message)
{
// Ignore debug logging from smtp
}
public void Trace(object message)
{
// Ignore trace logging from smtp
}
public void Trace(object message, byte[] data)
{
// Ignore trace logging from smtp
}
}