title: unable to get log4net working with .net windows service
body: <p>I have a windows service with an <code>app.config</code> and a <code>log4net.config</code>.</p>
  
  <p><code>app.config</code>:</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 configSource="log4net.config" /&gt;
  </code></pre>
  
  <p><code>log4net.config</code>:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;log4net&gt;
    &lt;appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
      &lt;param name="File" value="D:\Projects\Integration\Interface Module\bin\Logs\MyFirstLogger.log"/&gt;
      &lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock" /&gt;
      &lt;appendToFile value="true" /&gt;
      &lt;rollingStyle value="Size" /&gt;
      &lt;maxSizeRollBackups value="2" /&gt;
      &lt;maximumFileSize value="1MB" /&gt;
      &lt;staticLogFileName value="true" /&gt;
      &lt;layout type="log4net.Layout.PatternLayout"&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>I have added this in <code>AssemblyInfo.cs</code> too:</p>
  
  <pre><code>[assembly: log4net.Config.XmlConfigurator(Watch = true)]
  </code></pre>
  
  <p>And in one of my classes, I have:</p>
  
  <pre><code>private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>_log.Info(content);
  </code></pre>
  
  <p>I have given <strong>all</strong> users full permissions to my Logs folder. </p>
  
  <p>My bin folder (which the service is running from) has both my <code>app.config</code> and <code>log4net.config</code>.</p>
  
  <p>But no logging file got generated. What settings did I miss?</p>
  
  <p><strong>Updated on 4-March-2014</strong></p>
  
  <p>If you are using a separate config file like I did (log4net.config), do remember to set the <code>Copy to output directory</code> setting to <code>Copy always</code> in the Solution Explorer</p>