Background
I wanted some properties to be available in the logging events for certain loggers. After doing some research on the subject I came up with the following possible solutions:
- Writing my own wrappers and using them instead of
log4net.ILogandlog4net.LogManager. - Subclassing
log4net.Appenders.ForwardingAppender. - Implement an
log4net.Hierarchy.ILoggerFactoryand create loggers that I derive fromlog4net.Hierarchy.Loggerthat add the properties I want.
The ILoggerFactory solution seemed like the easiest to implement and and gives me exactly what I want, nothing more, nothing less.
Question
How do I specify which ILoggerFactory log4net should use in the correct way? I'm currently doing this during the startup of my application:
XmlConfigurator.Configure();
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
hierarchy.LoggerFactory = new LoggerFactory();
It works for now but I do not fully understand every tiny bit of the log4net design so I do not know if it will blow up on me. Is it even supported writing a custom ILoggerFactory?