2

I have an asp.net website that is utilizing log4net. Due to several third party libraries (like NHibernate), there are several appenders across multiple threads. IIS is setup so there should be only one process. I have confirmed this by utilizing the process id in the filename.

Web.config Excerpt:

<appender name="AppAppender" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="Logs\App_[%processid]_.log" />
    <appendToFile value="true" />
    <rollingStyle value="Composite" />
    <datePattern value="yyyy-MM-dd" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="10MB" />
    <staticLogFileName value="false" />
    <preserveLogFileNameExtension value="true" />
    <threshold value="DEBUG" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value=" %date %-5level [%property{SessionId}] - %message%newline" />
    </layout>
</appender>

When recycling the app pool in IIS I sometimes get these errors:

log4net:ERROR [RollingFileAppender] ErrorCode: GenericFailure. Unable to acquire lock on file App_[6844]_2014-12-18.log. Access to the path 'App_[6844]_2014-12-18.log' is denied.

My question, is are some of these error inevitable because its multi-threaded, or if configured properly should they never occur.

Additional Info:

  • I'm using log4net 1.2.13 (installed over nuget)
  • Frozen Mountain's WebSync (3.5.1.3), also note that this library directly references log4net 1.2.11, I used a bindingRedirect to 1.2.13
  • NHibernate version 3.1.0.400, it was the first version to not use log4net 1.2.10

**NHibernate can easily be upgraded if we think thats the problem. WebSync would be more difficult.

texel
  • 184
  • 9
  • Do you only get these errors when recycling the app pool, and not during normal operation? – stuartd Dec 19 '14 at 11:08
  • The production site is using log4net 1.2.10 which has some other issues (However, it does have it during normal use). My dev site hasn't shown the problem during normal use (only during app pool recycling). However, it hasn't really been tested enough to say with any real certainty. – texel Dec 19 '14 at 14:31

0 Answers0