log4net will not read from app.config
It seems that the app.config file was not configured to be watched by log4net.
I added the following line to AssemblyInfo.cs
and logging is now enabled:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
Weird, since I didn't add this line to the the project that was working.
EDIT:
Looks like the project that was working did have the line after all. I must have forgotten.
// This will cause log4net to look for a configuration file
// called [ThisApp].exe.config in the application base
// directory (i.e. the directory containing [ThisApp].exe)
// The config file will be watched for changes.
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
The solution for me was to use XmlConfigurator.Configure()
in the program's startup code. However, my situation differed in that I was using the Autofac.log4net module to register the ILog
in an Autofac container. In this instance, using XmlConfiguratorAttribute
(with Watch
set to either true or false) left the logger unconfigured.