我花了整個上午都通過了一整套的可能性,爲什麼log4net的不寫文件時,根據設置的SharePoint 2010log4net的,缺少魔法
我已經試過單獨的log4net的文件涉水路由,但我目前正在嘗試它在web.config中配置它。
我在web.config中更新了對介質的信任,而log4net dll也在GAC中。當我斷點時,我的記錄器看起來不錯,所有日誌記錄啓用,但是.Info()通過沒有錯誤,但日誌文件沒有創建。
祝你好運我已經給所有人& asp.net應用程序池runas用戶完全控制根日誌文件夾。這裏的配置片斷和App_Start代碼:
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
...
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
private static ILog logger;
protected void Application_Start(object sender, EventArgs e)
{
////This tells log4net where to go and look for its configuration file and also to watch it for any changes
//log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(@"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Config\Moogle\Log4Net.config"));
SPSecurity.RunWithElevatedPrivileges(delegate
{
log4net.Config.XmlConfigurator.Configure();
logger = LogManager.GetLogger("Moogle.Web");
logger.Info("Application_Start Fired");
});
}
編輯 已經更新我的配置上面(見我的答案),我仍然得到log4net的消息:
log4net: XmlHierarchyConfigurator: Hierarchy Threshold []
log4net: Logger: No appenders could be found for logger [Moogle.Web] repository [log4net-default-repository]
log4net: Logger: Please initialize the log4net system properly.
任何想法?