Something that may work for you is to create a class that implements IErrorHandler for each appender, then configure each appender to use the custom error handling class. This should give you more control than enabling log4net.Internal.Debug.
I've just given this a try and it works (note that in my sample Logger
is a log4net logger defined elsewhere - the aim behin this is capture errors from an SMTP appender and log them to a file):
using System;
using log4net.Core;
namespace Test
{
public class SmtpErrorHandler : IErrorHandler
{
public void Error(string message)
{
Logger.Log.Error(message);
}
public void Error(string message, Exception ex)
{
Logger.Log.Error(message, ex);
}
public void Error(string message, Exception ex, ErrorCode errorCode)
{
Logger.Log.Error(String.Format("{0}{1}Error code: {2}", message, Environment.NewLine, errorCode), ex);
}
}
}
Where I configure my appender (of course you can do this in the config too):
emailAppender.ErrorHandler = new SmtpErrorHandler();