title: Log4Net - Process Lock on Files
body: <p>We're using Log4Net with a FileAppender to log errors during a process. As the process is finishing, we want to email the log file but we can't do that as it Log4Net still has a lock on the file and we get a message that the file is in use by another process. Any ideas?</p>
  
  <p>We're using a config like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>  &lt;appender name="WarnFileAppender" type="log4net.Appender.FileAppender"&gt;
      &lt;file value="d:\for-review-log.txt" /&gt;
  
      &lt;layout type="log4net.Layout.PatternLayout"&gt;
        &lt;conversionPattern value="%date %logger - %message%newline" /&gt;
      &lt;/layout&gt;
      &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
        &lt;levelMin value="INFO" /&gt;
        &lt;levelMax value="WARN" /&gt;
      &lt;/filter&gt;
      &lt;filter type="log4net.Filter.DenyAllFilter" /&gt;
      &lt;appendToFile  value="false"&gt;&lt;/appendToFile&gt;
      &lt;lockingModel type="log4net.Appender.FileAppender+MinimalLock" /&gt;
    &lt;/appender&gt;
  </code></pre>