[英]Changing app.config for Entity Framework and log4net
I'm using Entity Framework along with log4net in my Console Application. 我在控制台应用程序中使用Entity Framework和log4net。 Here's what my app.config looks like: 这是我的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>
I get a "ConfigErrorsException was unhandled" error. 我收到“未处理ConfigErrorsException”错误。 It's pointing to my CAPDBEntities that I've set up. 它指向我已设置的CAPDBEntities。 What do I have to change to have both EF & log4net working using the same app.config file? 要使EF和log4net都使用同一app.config文件工作,我需要更改什么?
I think I figured this out. 我想我明白了。 I downloaded Entity Framework from Nuget & recreated App.config. 我从Nuget下载了Entity Framework,并重新创建了App.config。 It worked after that. 在那之后它起作用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.