This project is read-only.

set up log4net

Mar 9, 2009 at 6:36 PM
Hello,

I've been trying to set up log4net but it's not working.

I've added inside <configSections>:

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
   
And in <configuration>

  <log4net debug="true">
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender, log4net">
      <threshold value="DEBUG"/>
      <file value="logfile.log"/>
      <appendToFile value="true"/>
      <rollingStyle value="Date"/>
      <datePattern value="yyyy-MM-dd"/>
      <layout type="log4net.Layout.PatternLayout, log4net">
        <conversionPattern value="%utcdate %-5level %logger - %message%newline"/>
      </layout>
    </appender>
    <root>
      <level value="DEBUG"/>
      <appender-ref ref="RollingFile"/>
    </root>
  </log4net>

From the class that I want to use it, I add the reference to log4net.dll and I create the attribute:

private static readonly ILog logger = LogManager.GetLogger(typeof (RootWithRedirectToCorrectLanguageRoot));

and to log:

logger.Debug("FindPath called");

But seems that it's not getting the configuration from web.config and not creating the logfile.log.

Thx,
P