2

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.

8
  • it is due to you have set its limit in configuration <maximumFileSize value="10MB" /> Commented Jul 6, 2016 at 13:11
  • From what I understand with log4Net, the maximumFileSize is the size the file will reach before it creates another file (in the rollingFileAppender).
    – Jason W
    Commented Jul 6, 2016 at 13:14
  • There's nothing wrong with this config, it matches mine almost verbatim (other than the locking model you added and mine is 4096KB size)
    – DavidG
    Commented Jul 6, 2016 at 13:19
  • Do you know of any other issues/reasons with log4Net, that it wouldn't create the rolling files?
    – Jason W
    Commented Jul 6, 2016 at 13:24
  • Perhaps a permissions issue? Does it have ability to create files in that folder?
    – DavidG
    Commented Jul 6, 2016 at 13:30

1 Answer 1

5

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.