2
我的App.config在下面給出。該文件是在同一個項目的來電:Log4Net配置XML
log4net.Config.XmlConfigurator.Configure();
private static log4net.ILog Log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
但是我收到:
log4net的:ERROR XmlConfigurator無法找到應用程序的.config文件配置部件「log4net的」。檢查您的.config文件中的
<log4net>
和<configSections>
元素。配置部分應該看起來像:<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>