[ 
https://issues.apache.org/jira/browse/LOG4NET-506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Frédéric Delaporte updated LOG4NET-506:
---------------------------------------
    Description: 
*Abstract:*
In some configuration cases, the rolling file appender may issue a mutex lock 
on the folder name. If more than one processes try to do that with different 
executing identity, only one will be able to log to its specific logs file. The 
others will no more be able to do it.

*Repro:*
Many applications run on the same server.
All run under different windows identity.
All do log through {{RollingFileAppender}} to D:\Logs\ (value of {{file}} 
configuration node) to their own file log (filename specific to each 
application through {{datePattern}} configuration node, like 
{{yyyy.MM.dd'-App1.log'}}, {{yyyy.MM.dd'-App2.log'}}, ...).
They log through {{AdoNetAppender}} too.

Since having upgraded Log4Net from 1.2.13 to 1.2.15 on some applications, they 
cease being able to all log to D:\Logs\. Only one of them still do log, 
depending on which have started first. SQL logs still work. Non upgraded 
applications are still able to log to D:\Logs\, whatever their start order have 
been.

*Diagnosis info:*
Activating log4net debug trace on an application, and comparing failure cases 
to working cases, yields following diff:

{code:title=failing case debug trace}
log4net:ERROR Could not create Appender [RollingLogFileAppender] of type 
[log4net.Appender.RollingFileAppender]. Reported error follows.
System.UnauthorizedAccessException: Access to path 'D__Logs_' denied. 
(Translated from french)
   à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   à System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData)
   à 
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
 code, CleanupCode backoutCode, Object userData)
   à  System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean 
initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES secAttrs)
   à  System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, 
Boolean& createdNew, MutexSecurity mutexSecurity)
   à  System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, 
Boolean& createdNew)
   à  log4net.Appender.RollingFileAppender.ActivateOptions()
   à  
log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement 
appenderElement)
log4net:ERROR Appender named [RollingLogFileAppender] not found.
{code}

{code:title=working case corresponding trace}
log4net: Searched for existing files in [D:\Logs]
log4net: curSizeRollBackups starts at [0]
log4net: Opening file for writing [D:\Logs\2016.02.26-App1.log] append [True]
log4net: Created Appender [RollingLogFileAppender]
log4net: Adding appender named [RollingLogFileAppender] to logger [root].
{code}
(All other trace lines are identical)

{code:xml|title=Application appender configuration}
  <appender name="RollingLogFileAppender" 
type="log4net.Appender.RollingFileAppender">
    <file value="D:\Logs\" />
    <datePattern value="yyyy.MM.dd'-App1.log'" />
    <staticLogFileName value="false" />
    <appendToFile value="true" />
    <rollingStyle value="Composite" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="5MB" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message - 
%property%newline%exception" />
    </layout>
  </appender>
{code}

  was:
*Abstract:*
In some configuration cases, the rolling file appender may issue a mutex lock 
on the folder name. If more than one processes try to do that with different 
executing identity, only one will be able to log to its specific logs file. The 
others will no more be able to do it.

*Repro:*
Many applications run on the same server.
Some are windows services running under "Local system" identity, others are IIS 
hosted web sites running under "Application pool" identity.
All do log through {{RollingFileAppender}} to D:\Logs\ (value of {{file}} 
configuration node) to their own file log (filename specific to each 
application through {{datePattern}} configuration node).
They log through {{AdoNetAppender}} too.

Since having upgraded Log4Net from 1.2.13 to 1.2.15 on all services and some 
web sites, upgraded IIS web sites cease being able to log to D:\Logs\. SQL logs 
still work. Non upgraded web site are still able to log to D:\Logs\.

The services start before the web sites.
Stopping all services then restarting a web site allows it to log again in 
D:\Logs\. Restarting a second web site (having a different application pool) 
while the first is still running does not allow the second one to log again in 
D:\Logs\ (Application pool identity give different identity to each pool).

*Diagnosis info:*
Activating log4net debug trace on a web site, and comparing failure cases to 
working cases, yields following diff:

{code:title=failing case debug trace}
log4net:ERROR Could not create Appender [RollingLogFileAppender] of type 
[log4net.Appender.RollingFileAppender]. Reported error follows.
System.UnauthorizedAccessException: L'accès au chemin d'accès 'D__Logs_' est 
refusé.
   à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   à System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData)
   à 
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
 code, CleanupCode backoutCode, Object userData)
   à  System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean 
initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES secAttrs)
   à  System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, 
Boolean& createdNew, MutexSecurity mutexSecurity)
   à  System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, 
Boolean& createdNew)
   à  log4net.Appender.RollingFileAppender.ActivateOptions()
   à  
log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement 
appenderElement)
log4net:ERROR Appender named [RollingLogFileAppender] not found.
{code}

{code:title=working case corresponding trace}
log4net: Searched for existing files in [D:\Logs]
log4net: curSizeRollBackups starts at [0]
log4net: Opening file for writing [D:\Logs\2016.02.26-WebSite1.log] append 
[True]
log4net: Created Appender [RollingLogFileAppender]
log4net: Adding appender named [RollingLogFileAppender] to logger [root].
{code}
(All other trace lines are identical)

{code:xml|title=WebSite appender configuration}
  <appender name="RollingLogFileAppender" 
type="log4net.Appender.RollingFileAppender">
    <file value="D:\Logs\" />
    <datePattern value="yyyy.MM.dd'-WebSite1.log'" />
    <staticLogFileName value="false" />
    <appendToFile value="true" />
    <rollingStyle value="Composite" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="5MB" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message - 
%property%newline%exception" />
    </layout>
  </appender>
{code}

{code:xml|title=Svc appender configuration}
  <appender name="RollingLogFileAppender" 
type="log4net.Appender.RollingFileAppender">
    <file value="D:\Logs\" />
    <datePattern value="yyyy.MM.dd'-Svc1.log'" />
    <staticLogFileName value="false" />
    <appendToFile value="true" />
    <rollingStyle value="Composite" />
    <maxSizeRollBackups value="10" />
    <maximumFileSize value="5MB" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %logger - %message - 
%property%newline%exception" />
    </layout>
  </appender>
{code}


> RollingFileAppender locking log folder in some cases
> ----------------------------------------------------
>
>                 Key: LOG4NET-506
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-506
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.15
>         Environment: Windows Server 2008 R2, Windows Server 2012 R2
>            Reporter: Frédéric Delaporte
>            Priority: Minor
>         Attachments: SiteAlone_log4net.txt, SiteWithSvc_log4net.txt
>
>
> *Abstract:*
> In some configuration cases, the rolling file appender may issue a mutex lock 
> on the folder name. If more than one processes try to do that with different 
> executing identity, only one will be able to log to its specific logs file. 
> The others will no more be able to do it.
> *Repro:*
> Many applications run on the same server.
> All run under different windows identity.
> All do log through {{RollingFileAppender}} to D:\Logs\ (value of {{file}} 
> configuration node) to their own file log (filename specific to each 
> application through {{datePattern}} configuration node, like 
> {{yyyy.MM.dd'-App1.log'}}, {{yyyy.MM.dd'-App2.log'}}, ...).
> They log through {{AdoNetAppender}} too.
> Since having upgraded Log4Net from 1.2.13 to 1.2.15 on some applications, 
> they cease being able to all log to D:\Logs\. Only one of them still do log, 
> depending on which have started first. SQL logs still work. Non upgraded 
> applications are still able to log to D:\Logs\, whatever their start order 
> have been.
> *Diagnosis info:*
> Activating log4net debug trace on an application, and comparing failure cases 
> to working cases, yields following diff:
> {code:title=failing case debug trace}
> log4net:ERROR Could not create Appender [RollingLogFileAppender] of type 
> [log4net.Appender.RollingFileAppender]. Reported error follows.
> System.UnauthorizedAccessException: Access to path 'D__Logs_' denied. 
> (Translated from french)
>    à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
>    à System.Threading.Mutex.MutexTryCodeHelper.MutexTryCode(Object userData)
>    à 
> System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
>  code, CleanupCode backoutCode, Object userData)
>    à  System.Threading.Mutex.CreateMutexWithGuaranteedCleanup(Boolean 
> initiallyOwned, String name, Boolean& createdNew, SECURITY_ATTRIBUTES 
> secAttrs)
>    à  System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, 
> Boolean& createdNew, MutexSecurity mutexSecurity)
>    à  System.Threading.Mutex..ctor(Boolean initiallyOwned, String name, 
> Boolean& createdNew)
>    à  log4net.Appender.RollingFileAppender.ActivateOptions()
>    à  
> log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement
>  appenderElement)
> log4net:ERROR Appender named [RollingLogFileAppender] not found.
> {code}
> {code:title=working case corresponding trace}
> log4net: Searched for existing files in [D:\Logs]
> log4net: curSizeRollBackups starts at [0]
> log4net: Opening file for writing [D:\Logs\2016.02.26-App1.log] append [True]
> log4net: Created Appender [RollingLogFileAppender]
> log4net: Adding appender named [RollingLogFileAppender] to logger [root].
> {code}
> (All other trace lines are identical)
> {code:xml|title=Application appender configuration}
>   <appender name="RollingLogFileAppender" 
> type="log4net.Appender.RollingFileAppender">
>     <file value="D:\Logs\" />
>     <datePattern value="yyyy.MM.dd'-App1.log'" />
>     <staticLogFileName value="false" />
>     <appendToFile value="true" />
>     <rollingStyle value="Composite" />
>     <maxSizeRollBackups value="10" />
>     <maximumFileSize value="5MB" />
>     <layout type="log4net.Layout.PatternLayout">
>       <conversionPattern value="%date [%thread] %-5level %logger - %message - 
> %property%newline%exception" />
>     </layout>
>   </appender>
> {code}



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

Reply via email to