2
故障得到了以下異常Common.Logging配置。與log4net的適配器
無法獲得從配置 節「共同/日誌」 Common.Logging配置。
試圖運行下面的代碼
Common.Logging.ILog logger = Common.Logging.LogManager.GetCurrentClassLogger();
App.Config中:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
</common>
<log4net>
<root>
<level value="ALL" />
<appender-ref ref="FileAppender" />
</root>
<appender name="FileAppender" type="log4net.Appender.FileAppender" >
<param name="File" value="log.txt" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
</log4net>
<connectionStrings>
<add name="ManagementEntities" connectionString="metadata=res://*/Model.ManagementModel.csdl|res://*/Model.ManagementModel.ssdl|res://*/Model.ManagementModel.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\Data\Management.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
有一個類似的問題 - 問題出現在NuGet包中。使用解決方案>管理NuGet軟件包(在Installed Packaged下)刪除了所有內容,並且只添加了Common.Logging軟件包。 – bengrine 2012-07-12 21:57:43