gpt4 book ai didi

c# - Log4Net 配置 XML

转载 作者:行者123 更新时间:2023-12-02 01:21:49 25 4
gpt4 key购买 nike

我的App.config如下。该文件与调用相同的项目:

log4net.Config.XmlConfigurator.Configure();
private static log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

但是我收到:

Log4net: ERROR XmlConfigurator Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" /

我觉得我犯了一个愚蠢的错误,因为我刚刚开始使用 log4net。有什么帮助吗?

<!-- language: xml -->

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>

<log4net>

<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\log-file.txt" />
<appendToFile value="true"/>
<rollingStyle value="Size" />
<maximumFileSize value="1MB" />
<staticLogFileName value="true" />
<maxSizeRollBackups value="10" />
<conversionPattern value="%date [%thread] %-5level %location %logger - %message%newline" />
<layout type="log4net.Layout.SimpleLayout" />
</appender>

<root>
<level value="ALL" />
<appender-ref ref="RollingFileAppender" />
</root>
</log4net>
</configuration>

最佳答案

我在您的 web.config 中立即看到的唯一一件事是您缺少结束标记。

关于c# - Log4Net 配置 XML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3292839/

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