我在控制台应用程序中使用实体框架和 log4net。这是我的 app.config 的样子:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<param name="File" value="C:\\Temp\\Logs\\"/>
<param name="RollingStyle" value="Date"/>
<param name="DatePattern" value="yyMMdd_HHmm'.log'" />
<param name="StaticLogFileName" value="false"/>
<appendToFile value="true" />
<maximumFileSize value="100KB" />
<maxSizeRollBackups value="2" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{MM/dd/yyyy HH:mm:ss} %logger [%thread] (Line :%line) %level - %message%newline"/>
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</root>
</log4net>
<connectionStrings>
<add name="CAPDBEntities" connectionString="metadata=res://*/CAPDB.csdl|res://*/CAPDB.ssdl|res://*/CAPDB.msl;provider=System.Data.SqlClient;provider connection string="data source=caServer;initial catalog=CAPDB;persist security info=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="USPDBEntities" connectionString="metadata=res://*/USPDB.csdl|res://*/USPDB.ssdl|res://*/USPDB.msl;provider=System.Data.SqlClient;provider connection string="data source=UsServer;initial catalog=USPDB;persist security info=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
我收到“ConfigErrorsException 未处理”错误。它指向我设置的 CAPDBEntities。为了让 EF 和 log4net 都使用同一个 app.config 文件工作,我需要进行哪些更改?