除了明显的候选(非法文件路径、权限错误)之外,问题甚至可能是互斥锁:
https://issues.apache.org/jira/browse/LOG4NET-506
RollingFileAppender 在某些情况下锁定日志文件夹
摘要:
在某些配置情况下,滚动文件附加程序可能
对文件夹名称发出互斥锁。如果有多个进程尝试
要使用不同的执行身份来做到这一点,只有一个人能够
记录到其特定的日志文件。其他人将无法再做
它。
建议:
将此行添加到您的 app.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.
请试试这个,然后发回你找到的东西!