From what i see in the code, appenders are created by the XmlHierarchyConfigurator
class, in the ParseAppender
method:
protected IAppender ParseAppender(XmlElement appenderElement)
{
string attribute = appenderElement.GetAttribute("name");
string attribute2 = appenderElement.GetAttribute("type");
// <snip>
try
{
IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(attribute2, true, true));
appender.Name = attribute;
// <snip>
The method finishes loading the appender by calling a method implemented by the IOptionHandler
interface (you already have it in your appender, because you have the AppenderSkeleton
class in your ancestors tree)
IOptionHandler optionHandler = appender as IOptionHandler;
if (optionHandler != null)
{
optionHandler.ActivateOptions();
}
Any xml parameter that is not known by log4net is pushed to a property with the same name. So it is possible to configure your appender entirely from the xml config file and launch any specific behavior you need by having your appender implement IOptionHandler
The only way (bar rebuilding a custom log4net) you have to pass a Func<ClientLoggerClient>
to your appender is to use a static event that you appender will call in the ActivateOptions()
method, event that would be picked up by your resolving method of choice; the event can contain some customization coming from the xml configuration for the appender, so you can route the resolution based on that. Let the event give back the adequate Func<ClientLoggerClient>
to your appender and you are good to go.