I cannot make log4net work in my web application :(
- by vtortola
Hi,
I'm trying to set up log4net but I cannot make it work. I've put this in my Web.config:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="logfile.log" />
<appendToFile value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="14" />
<maximumFileSize value="15000KB" />
<datePattern value="yyyyMMdd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="TraceAppender" />
</root>
(StackOverflow is not rendering correctly the code I've pasted, I don't know why)
Then, in my code I execute:
log4net.Config.XmlConfigurator.Configure(new FileInfo(HttpContext.Current.Server.MapPath("~/Web.config")));
ILog log = LogManager.GetLogger("MainLogger");
if(log.IsDebugEnabled)
log.Debug("lalala");
But nothing happen. I check the "log" variable, and contains an LogImpl object, that has all the logging levels enabled. I get no error or configuration warning, I cannot see any file in the root, in the bin or anywhere.
What do I have to do to make it work?
Cheers.