我正在使用log4net进行日志记录。我的日志配置存储在一个单独的文件中。
Web.Config:ConfigSections
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />在AssemblyInfo.cs中指定配置文件
[assembly: log4net.Config.XmlConfigurator(ConfigFile="Log4Net.config", Watch = true)] 当我初始化我的LogManager时,我得到了这个错误
"System.TypeLoadException"
message: Could not load type 'log4net.Config.Log4NetConfigurationSectionHlandler' from assembly 'Log4net'.是的,它写着“Log4NetConfigurationSectionHlandler”,这不是一个打字错误
后来,这个错误
An error occurred creating the configuration section handler for log4net: Could not load type 'log4net.Config.Log4NetConfigurationSectionHlandler' from assembly 'Log4net'. 编辑:尝试了Mauricio Scheffer的建议
得到
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" />发布于 2009-12-19 03:05:57
如果您的配置在单独的log4net.config文件中,则不需要sectionHandler。去掉它。
您还可能在代码中的某处调用XmlConfigurator.Configure()。把它也去掉。
另请参阅this question
https://stackoverflow.com/questions/1930083
复制相似问题