title: Log4Net Error: Failed to find configuration section 'log4net' in the application's .config file
body: <p>I currently use a class library to store a class that handles logging using log4net. This class is used in other projects.</p>
  
  <p>I've read a lot of other questions and answers, but I haven't been able to fix it yet...</p>
  
  <p>I enabled internal debugging of log4net because it would not write to a file, and this is the error I get: </p>
  
  <pre><code>log4net:ERROR Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the &lt;log4net&gt; and &lt;configSections&gt; elements. The configuration section should look like: &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /&gt;
  </code></pre>
  
  <p>These are my files:
  <em>log4net.config</em></p>
  
  <pre><code>&lt;log4net debug="true"&gt;
      &lt;appender name="LogFileAppender" type="log4net.Appender.FileAppender"&gt;
          &lt;param name="File" value="Logs/log4net.log" /&gt;
          &lt;param name="AppendToFile" value="true" /&gt;
          &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;param name="Header" value="[Header]\r\n" /&gt;
          &lt;param name="Footer" value="[Footer]\r\n" /&gt;
          &lt;param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" /&gt;
          &lt;/layout&gt;
      &lt;/appender&gt;
  
      &lt;root&gt;
          &lt;level value="ALL" /&gt;
          &lt;appender-ref ref="LogFileAppender" /&gt;
      &lt;/root&gt;
  &lt;/log4net&gt;
  </code></pre>
  
  <p><em>App.config</em></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
      &lt;configuration&gt;
        &lt;configSections&gt;
          &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /&gt;
        &lt;/configSections&gt;
  
        &lt;appSettings&gt;
          &lt;add key="log4net.Internal.Debug" value="true"/&gt;
        &lt;/appSettings&gt;
  
        &lt;parameter&gt;
          &lt;parameterName value="@BlogId" /&gt;
          &lt;dbType value="Int32" /&gt;
          &lt;layout type="log4net.Layout.RawPropertyLayout"&gt;
            &lt;key value="BlogId" /&gt;
          &lt;/layout&gt;
        &lt;/parameter&gt;
      &lt;/configuration&gt;
  </code></pre>
  
  <p><em>AssemblyInfo.cs</em> (just last line)</p>
  
  <pre><code>[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
  </code></pre>
  
  <p><em>Logger.cs</em></p>
  
  <pre><code>public class Logger : ILogger
      {
          private static ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  
          public Logger()
          {
              XmlConfigurator.Configure();
              logger.Info("NEW LOGGER INSTANCE CREATED");
          }
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  I fixed it by letting the class that uses my Logger.cs give its own .config file for log4net. Now log4net reads the given .config files and it works.</p>