title: Log4Net RollingFileAppender not flushing IO buffer with low volume log
body: <p>I'm pondering on the <a href="http://apache-logging.6191.n7.nabble.com/Turning-off-buffered-IO-for-the-RollingFileAppenders-td22224.html" rel="noreferrer">same issue as HENRI COOK did</a>. It's been reported as a <a href="https://issues.apache.org/jira/browse/LOG4NET-336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel" rel="noreferrer">bug on Apache Jira</a> as far as we can tell from the short description. </p>
  
  <p>My problem in essence is that events are only logged when the application is shut down (even weeks after the event). That happens when logging volume is very low. I'm seeing this on a Windows Server 2008 R2. This prevents us from capturing and reacting to production errors.</p>
  
  <p>Now the appender is not a buffering one. By default it also calls Flush() on the underlying stream every time a message is appended. </p>
  
  <p>My question is WHY is it not flushing? And is there any remedy besides <a href="https://stackoverflow.com/questions/2045935/is-there-anyway-to-programmably-flush-the-buffer-in-log4net">programatically flushing all appenders</a>? Would you consider a <a href="https://issues.apache.org/jira/browse/LOG4NET-83?focusedCommentId=13551218&amp;page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13551218" rel="noreferrer">pulsing appender</a> a viable workaround? </p>
  
  <p>The appender config:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;appender name="RollingErrorFileAppender" type="log4net.Appender.RollingFileAppender"&gt;
    &lt;param name="File" value="D:\LogFiles\zzzz\xxxxxx__ERROR" /&gt;
    &lt;param name="AppendToFile" value="true" /&gt;
    &lt;param name="DatePattern" value="_yyyyMMddHH&amp;quot;.log&amp;quot;" /&gt;
    &lt;param name="RollingStyle" value="Date" /&gt;
    &lt;param name="StaticLogFileName" value="false" /&gt;
    &lt;filter type="log4net.Filter.LevelRangeFilter"&gt;
      &lt;param name="LevelMin" value="ERROR" /&gt;
      &lt;param name="LevelMax" value="FATAL" /&gt;
    &lt;/filter&gt;
    &lt;layout type="log4net.Layout.PatternLayout"&gt;
      &lt;param name="ConversionPattern" value="%utcdate{yyyy-MM-dd HH:mm:ss.fff},[%thread],%level,%logger,%m%n"/&gt;
    &lt;/layout&gt;
  &lt;/appender&gt;
  </code></pre>
  
  <p>UPDATE 2013-06-19</p>
  
  <p>I haven't been able to reproduce the behavior with any code. No matter how bad I try, the data is always written to the disk immediately. However, an important observation was made: If the first write to a file is larger than 1KiB, the modified-time is never updated with subsequent writes. It will only be updated when the file is closed with the time of closure. If on the other hand the first write is a short one-liner, any subsequent write will update the modified-time. This behavior is consistent between log4net and manual IO operation, between 32bit WinXP and 64bit W2k8R2, between .NET 2.0, 3.5 and .NET 4.0. That doesn't solve the problem still, but at least I can understand the strange modification-time pattern now.</p>
  
  <p>Thanks, Rob</p>