gpt4 book ai didi

log4net,这个配置怎么了

转载 作者:行者123 更新时间:2023-12-01 23:11:52 25 4
gpt4 key购买 nike

log4net 正在报告:

No appenders could be found for logger log4net: Logger: Please initialize the log4net system properly.

我有一个独立的 log4net 配置文件:

<!--?xml version="1.0"?-->
<configuration>
<configsections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
</configsections>
<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>
</configuration>

..以及这个应用程序的启动代码

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"));
logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
logger.Debug("Application_Start Fired");

最佳答案

您只定义了一个附加程序。您还需要定义一个根记录器和一个使用附加器的记录器(如果您只需要一个记录器,它们可以是同一个记录器)。将以下根元素添加到您的 log4net 配置中。

<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>

关于log4net,这个配置怎么了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8940026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com