.net 如何使用EnterpriseLibrary和模拟登录到数据库?

.net 如何使用EnterpriseLibrary和模拟登录到数据库?,.net,database,logging,enterprise-library,impersonation,.net,Database,Logging,Enterprise Library,Impersonation,我正在尝试使用企业库记录数据库的异常。我的应用程序设置在连接到数据库时使用模拟,但在尝试记录任何内容时,它似乎不起作用(在其余时间工作正常) <add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" /> <identi

我正在尝试使用企业库记录数据库的异常。我的应用程序设置在连接到数据库时使用模拟,但在尝试记录任何内容时,它似乎不起作用(在其余时间工作正常)

<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>
日志块是否忽略模拟,或者我是否遗漏了什么?跟踪数据库时,它显示一个错误,即计算机名正在尝试连接到数据库,而不是我用来模拟的服务帐户

<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>
以下是一些配置:

<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>

<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>

<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>

更新: 我在loggingConfiguration部分添加了revertImpersonation=“false”属性,但似乎没有任何效果

<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>
更新2: 如果其他人遇到同样的问题,这不是企业图书馆的问题。它与页面生命周期和模拟有关。在生命周期的这一点上(应用程序错误块),模拟尚未发生,因此它无法连接到数据库进行日志记录。对于这一部分,我改为在代码中手动启动模拟来解决这个问题

<add name="Reporting" connectionString="Data Source=reports\reportsdev;Initial Catalog=ReportsD;Integrated Security=True" providerName="System.Data.SqlClient" />

<identity impersonate="true" userName="name" password="pwd"/>