title: How to include log4net for a class library?
body: <p>I want to implement logging function into a class library, which is itself referenced in a webservice. I tried to add app.config and did everything needed, but it seems that when an exception is thrown, log4net simply does nothing.</p>
  
  <p>my app.config</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;configSections&gt;
      &lt;section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/&gt;
    &lt;/configSections&gt;
    &lt;log4net&gt;
      &lt;appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
        &lt;file value="D:\\mylogfile.txt" /&gt;
        &lt;appendToFile value="true" /&gt;
        &lt;rollingStyle value="Size" /&gt;
        &lt;maxSizeRollBackups value="5" /&gt;
        &lt;maximumFileSize value="10MB" /&gt;
        &lt;staticLogFileName value="true" /&gt;
        &lt;filter type="log4net.Filter.StringMatchFilter"&gt;
          &lt;stringToMatch value="test" /&gt;
        &lt;/filter&gt;
        &lt;filter type="log4net.Filter.StringMatchFilter"&gt;
          &lt;stringToMatch value="error" /&gt;
        &lt;/filter&gt;
        &lt;filter type="log4net.Filter.DenyAllFilter" /&gt;
        &lt;layout type="log4net.Layout.PatternLayout"&gt;
          &lt;conversionPattern value="%date [%thread] %level %logger - %message%newline%exception" /&gt;
        &lt;/layout&gt;
      &lt;/appender&gt;
      &lt;root&gt;
        &lt;level value="INFO"/&gt;
        &lt;appender-ref ref="RollingFileAppender"/&gt;
        &lt;appender-ref ref="ConsoleAppender" /&gt;
      &lt;/root&gt;
    &lt;/log4net&gt;
  </code></pre>
  
  <p>in AssemblyInfo.cs:</p>
  
  <pre><code>[assembly: log4net.Config.XmlConfigurator(ConfigFile = "app.config")]
  </code></pre>
  
  <p>in LogManager.cs:</p>
  
  <pre><code>private static readonly ILog Log = log4net.LogManager.GetLogger
              (MethodBase.GetCurrentMethod().DeclaringType);
  public static void WriteLog(Exception ex)
  {
      Log.Error(ex);
  }
  </code></pre>
  
  <p>Can you please tell me what's wrong? How can I get log4net working for my class library?</p>
  
  <p>Thank you</p>