I'm trying to use log4net with an external config file, but it does not work: nothing gets logged
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\\tmp\\test.log" />
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%level %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<appender-ref ref="RollingFile" />
</root>
</log4net>
If I use this line in Assembly.cs, test.lg is creatd when the BHO is registered with regasm, but not when the plugin is running:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = @"C:\\tmp\\test.log4net", Watch = true)]
When I use this code inside the BHO, no log is adde to test.log:
XmlConfigurator.Configure(new System.IO.FileInfo(@"C:\\tmp\\test.log4net"));
log.Info("test");
I'm not sure what I am doing wrong.
The log4net configuration file was fine. The problem is that Internet Explorer ran in Protected Mode, which forbids BHOs to write to arbitrary folders. There are only a few folders where the BHO can write.