In App.Config I declare a config section for my console application:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
And configure a ConsoleAppender:
<log4net>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>
We also declare a RollingFile appender in a logging util class that's part of our standard codebase at app-startup (which is not easily modified):
_hierarchy = (Hierarchy)LogManager.GetRepository();
_rollingFileAppender = new RollingFileAppender();
... //_rollingFileppender options
_rollingFileAppender.ActivateOptions();
_hierarchy.Root.AddAppender(_rollingFileAppender);
_hierarchy.Configured = true;
When I run the application, I see log-entries are written to files as expected but nothing is written to the console.
When I inspect my ILog instance in the debugger, I see no appenders at all in Logger.Appenders but I do see the RollingFileAppender instance as the only element in Root.Appenders.
log4net is something I am used to "it just works" - is there some incompatibility having config and code add appenders, or some line I need to get LogManager to look in app.config?
