使用Enterprise Library 5登录到SQL Azure可以从开发计算机运行,但不能从web角色运行



我正在使用企业库5使用SQL Azure作为日志存储库。我正在自己的计算机上运行一个完整的集成测试,使用azure的所有部署连接字符串和数据库连接字符串,并尝试将日志写入数据库。这很好用!

但是,当在临时环境中进行实际部署并尝试写入日志时,不会引发异常,但也不会写入日志。

以下是我的app.config相关部分:

 <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <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="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
  </configSections>
  <loggingConfiguration name="" tracingEnabled="true" defaultCategory="MainLogger"
      revertImpersonation="false">
    <listeners>
      <add name="LoggingDb" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          databaseInstanceName="LoggingDb" writeLogStoredProcName="WriteLog"
          addCategoryStoredProcName="AddCategory" traceOutputOptions="DateTime, Timestamp, ProcessId, ThreadId, Callstack" />
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
          name="Text Formatter" />
    </formatters>
    <categorySources>
      <add switchValue="All" name="MainLogger">
        <listeners>
          <add name="LoggingDb" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events">
        <listeners>
          <add name="LoggingDb" />
        </listeners>
      </allEvents>
      <notProcessed switchValue="All" name="Unprocessed Category">
        <listeners>
          <add name="LoggingDb" />
        </listeners>
      </notProcessed>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="LoggingDb" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <dataConfiguration defaultDatabase="LoggingDb" />
  <connectionStrings>
    <add name="LoggingDb" connectionString="Server=tcp:********.database.windows.net,1433;Database=****.Logging;User ID=*******@*******;Password=**********;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

我收到以下异常:

配置"listenerDataType="Microsoft.Practices.EnterpriseLibrary.Loggin.Database.configuration.FormattedDatabaseTraceListenerData,Microsoft.Practice.EnterpriseLibrary_Loggin.Data,Version=5.0414.0,Culture=neutral,PublicKeyToken=31bf3856a364e35"中的TraceListener数据类型无效。(E:\sitesroot\0\web.config第30行)

在Dev中工作时。。。对这件事有什么想法或经验吗?

问候,

James

是的,正如所评论的,以下是必须在您的服务目录中才能运行日志记录块的dll:

Microsoft.Practices.Unity.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Database.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll

相关内容

最新更新