dpsenner commented on a change in pull request #48: Fixes LOG4NET-587 Mutex ~
UnauthorizedAccessException Access to the path is denied
URL: https://github.com/apache/logging-log4net/pull/48#discussion_r287297240
##########
File path: src/Appender/FileAppender.cs
##########
@@ -876,6 +886,57 @@ public override void OnClose()
}
#endif
+ /// <summary>
+ /// Method for secure open or create Mutex with Synchronize and
Modify rights.
+ /// Using this method allows different users run processes
which can open or create a shared mutex without experiencing
UnauthorizedAccessException.
+ /// </summary>
+ /// <param name="mutexId">The mutex Id. Here we use a mutex
freindly name.</param>
+ /// <param name="errorHandler">Optional error handler, to log
potentialy occuring errors.</param>
+ /// <returns></returns>
+ protected static Mutex SecureCreateMutex(string mutexId,
IErrorHandler errorHandler)
+ {
+ // Using this mehotd to avoid the issue:
+ // Mutex ~ Access to the path is denied in
log4net.Appender.RollingFileAppender.ActivateOptions()
+ // https://jira.apache.org/jira/browse/LOG4NET-587
+ // Solution implemented according to:
+ // UnauthorizedAccessException when trying to open a
mutex
+ //
https://stackoverflow.com/questions/19536697/unauthorizedaccessexception-when-trying-to-open-a-mutex
+ //NOTE: there are several other jira issues reporting
this problem.
+ if (string.IsNullOrWhiteSpace(mutexId))
+ {
+ return null;
Review comment:
Would you please add an invocation to errorHandler such that even this rare
case appears in the internal logs of the framework?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services