You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "Dominik Psenner (JIRA)" <ji...@apache.org> on 2016/09/09 06:27:21 UTC

[jira] [Commented] (LOG4NET-525) RollingFileAppender initialization throws UnauthorizedAccessException while creating a mutex

    [ https://issues.apache.org/jira/browse/LOG4NET-525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15476074#comment-15476074 ] 

Dominik Psenner commented on LOG4NET-525:
-----------------------------------------

Since 1.2.14 log4net uses a mutex to make sure that rolling is done by one process only such that there is no possibility of race conditions when multiple applications append and roll on the same files. It would be nice if you could troubleshoot this issue on your side. Once we are able to reproduce the issue, we can write a test for it and fix it for good.

> RollingFileAppender initialization throws UnauthorizedAccessException while creating a mutex
> --------------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-525
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-525
>             Project: Log4net
>          Issue Type: Bug
>    Affects Versions: 1.2.15
>            Reporter: Brandon Johnson
>
> 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:
> {code}
> 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)
> {code}
> 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?
> {code}
> <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>
> {code}
> Let me know, thanks!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)