Search code examples
c#logginglog4neterror-logging

log4Net RollingFileAppender Does Not "Roll"


I am using log4Net to capture transaction data from an application, to help with debugging issues/errors basically. Lately, it hasn't been creating new files after the file size hits 10MB, it just stops recording data. I looked online and found a source saying I needed to added a MutexLock, so I did and nothing changed. My appender and root level sections are below:

<!-- Appenders section -->
<log4net>
  <appender name="file" type="log4net.Appender.RollingFileAppender">
    <file value="c:\programs\DocIt\production\documakerError.log"/>
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="10MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%d{yyyy-MM-dd HH:mm:ss.fff} [%thread] %-5p %c - %m%n"  />
    </layout>
    <lockingModel type="log4net.Appender.FileAppender+MutexLock" />
  </appender>
<!-- root section -->
<root>
  <level value="DEBUG"/>
  <appender-ref ref="file" />
</root>

Thanks for your help.


Solution

  • I have found the reason why I was not able to get log4Net to roll the files. It appears that the Modify permission on the file share was revoked from our service account. This allowed the service account to create new files, but wasn't able to rename them; which is crucial for the RollingFileAppender.