Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-525

RollingFileAppender initialization throws UnauthorizedAccessException while creating a mutex

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.2.15
    • None
    • None
    • None

    Description

      Hello,

      My team upgraded our ASP.NET web application from log4net 1.2.13 to 1.2.15 and lost logging functionality in one of our QA environments. log4net's internal logging reports:

      log4net:ERROR Could not create Appender [RollingLogFileAppenderServerQual] of type [log4net.Appender.RollingFileAppender]. Reported error follows.
      System.UnauthorizedAccessException: Access to the path 'D__AppLogs_AMS_AMSLogQual.log' is denied.
         at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
         at System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData)
         at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
         at System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES secAttrs)
         at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, Boolean& createdNew, MutexSecurity mutexSecurity)
         at System.Threading.Mutex..ctor(Boolean initiallyOwned, String name)
         at log4net.Appender.RollingFileAppender.ActivateOptions()
         at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
      

      After some confusion on our end I confirmed that downgrading log4net back to 1.2.13 avoids the problem. I am seeing similar bug reports from other users, often under different circumstances. E.g. LOG4NET-506 is about the parent folder of the log file being locked, but in our case it's the log file.

      Is remaining on 1.2.13 my only option? Or is there something I can change with my appender configuration?

      <appender name="RollingLogFileAppenderServerQual" type="log4net.Appender.RollingFileAppender">
            <file value="D:\\AppLogs\\AMS\\AMSLogQual.log" />
            <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
            <appendToFile value="true" />
            <rollingStyle value="Size" />
            <maximumFileSize value="20MB" />
            <maxSizeRollBackups value="10" />
            <staticLogFileName value="true" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%-23date [%-5thread] %-5level %logger %property{log4net:HostName} %username - (%location) - %message%newline" />
            </layout>
          </appender>
      

      Let me know, thanks!

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              bjohnson6 Brandon Johnson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: