I've been shown how to use log4net and got a config file to use. I lost this config file and now I cant get it to work. For some reason the guy who configured it could not get it to work while having the configuration info in app.config so he placed it in log4net.config in the output folder.
He then called this when the program started up:
var logConfig = Path.Combine(Path.GetDirectoryName(typeof(App).Assembly.Location), "log4net.config");
var configStream = new FileInfo(logConfig);
log4net.Config.XmlConfigurator.Configure(configStream);
And it worked flawlessly.
Now I got it to work perfectly in a new console project. However allmost all of my projects are addons to another application so my project types are class libraries loaded by this other application (called Revit).
Anyway, so I know that I can log, but just cant get it to work... This is log4net.config that I use:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<file value="logs\" />
<datePattern value="dd.MM.yyyy'.log'" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="RollingFileAppender"/>
</root>
</log4net>
Each class that I want to log stuff from declares the an ILog instance on the class level. Like this:
static private ILog _logger = LogManager.GetLogger(typeof(Program));
The ILog instance reports that all logging is enabled (debug and so on), but there are no files created.
Do I need to do anything else?
Im going nuts here! Thanks for any help!