现在我收到错误“无法在应用程序.config
文件中找到配置部分'log4net'”。这是我在log4net.config
文件中的代码:
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<root>
<level Value="Info"/>
<level Value="Error"/>
<appender-ref ref="ColoredFileAppender" />
</root>
<appender name="ColoredFileAppender" type="log4net.Appender.RollingFileAppender" >
<file type="log4net.Util.PatternString"/>
<file value="C:\CL2.html" />
<encoding value="utf-8" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<appendToFile value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%CC" />
<converter>
<name value="CC" />
<type value="Cluster2.ColoredMessageConverter" />
</converter>
<mapping>
<level value="Info" />
<foreColor value="Green" />
</mapping>
<mapping>
<level value="ERROR" />
<backColor value="Red, HighIntensity" />
</mapping>
</layout>
</appender>
</configuration>
</log4net>
我在程序集中包含了这个语句:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
我在我的程序中包含了这个语句:
protected void Application_start(Object Sender, EventArgs e)
{
log4net.Config.XmlConfigurator.Configure();
}
我不知道是什么问题。请帮忙。