gpt4 book ai didi

azure - 使用 Enterprise Library 5 登录到 SQL Azure 可以从开发计算机工作,但不能从 Web 角色工作

转载 作者:行者123 更新时间:2023-12-03 03:20:27 25 4
gpt4 key购买 nike

我使用 SQL Azure 作为使用企业库 5 的日志存储库。我正在使用 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.Logging.Database.Configuration.FormattedDatabaseTraceListenerData、Microsoft.Practices.EnterpriseLibrary.Logging.Database、Version=5.0.414.0、Culture=neutral、PublicKeyToken=31bf3856ad364e35”中的无效 TraceListenerData 类型'。 (E:\sitesroot\0\web.config 第 30 行)

在开发中它可以工作......对此有什么想法或经验吗?

问候,

詹姆斯

最佳答案

是的,正如所评论的,以下是必须位于您的服务目录中的 dll,以便日志记录 block 能够运行:

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

关于azure - 使用 Enterprise Library 5 登录到 SQL Azure 可以从开发计算机工作,但不能从 Web 角色工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9781405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com