log4net:错误无法创建 appender [RollingLogFileAppender]
log4net: error could not create appender [RollingLogFileAppender]
因此,我在 git 存储库中有一个项目,以及 2 个分支:master 和 fix-master。
我没有更改与 fix-master 中的 log4net 关联的代码。但是每次,当我启动 master - 我没有这个问题,如果我检查到 fix-master,我在这一行之后有这个错误:
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
除了明显的候选者(非法文件路径、权限错误)之外,问题甚至可能是互斥锁定:
https://issues.apache.org/jira/browse/LOG4NET-506
RollingFileAppender locking log folder in some cases
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.
建议:
将此行添加到您的应用程序。config/web.config,在 appSettings 下,以启用内部调试:
<add key="log4net.Internal.Debug" value="true"/>
这将为您提供系统控制台和 System.Diagnostics.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.
请试试这个,然后post返回你找到的东西!
因此,我在 git 存储库中有一个项目,以及 2 个分支:master 和 fix-master。 我没有更改与 fix-master 中的 log4net 关联的代码。但是每次,当我启动 master - 我没有这个问题,如果我检查到 fix-master,我在这一行之后有这个错误:
private static readonly ILog Log = LogManager.GetLogger(typeof(Program));
除了明显的候选者(非法文件路径、权限错误)之外,问题甚至可能是互斥锁定:
https://issues.apache.org/jira/browse/LOG4NET-506
RollingFileAppender locking log folder in some cases
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.
建议:
将此行添加到您的应用程序。config/web.config,在 appSettings 下,以启用内部调试:
<add key="log4net.Internal.Debug" value="true"/>
这将为您提供系统控制台和 System.Diagnostics.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.
请试试这个,然后post返回你找到的东西!