我正在使用 Windows Azure 诊断。我在 Webrol.cs 中添加以下代码
尝试
{
string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
RoleInstanceDiagnosticManager roleInstanceDiagnosticManager = storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);
DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();
//Windows Azure logs
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
//IIS 7.0 logs
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
////Failed Request logs
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
//Windows Event logs
// config.WindowsEventLog.DataSources.Add("System!*");
config.WindowsEventLog.DataSources.Add("Application!*");
config.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
////Crash dumps
CrashDumps.EnableCollection(true);
//update the config with changes
roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
}
catch (Exception ee)
{
System.Diagnostics.Trace.TraceWarning("Diagnostics failed");
}
以及 Web.config 中剩余的必需内容以及 .cscfg 文件中的连接字符串。 现在,我可以使用部署存储从开发环境中记录诊断信息。但是当我在云中托管相同的应用程序时,我无法记录诊断。我收到类似的错误
“500 - 内部服务器错误。 您要查找的资源有问题,无法显示。”
我尝试将命名空间的 Copy local 更改为 true,但这不起作用。 我希望应用程序能够在部署环境中运行。 如果有人有任何想法解决这个问题,请回复我。
提前致谢。
最佳答案
问题似乎是您没有更改“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”的连接字符串。您可以在 Web 角色项目或服务配置文件的设置中更改此设置。将其设置为您的帐户名和 key 。我通常使用构建脚本来执行此操作,以便在投入生产时可以更改它。您可以查看帖子here代码 here .
关于azure - Windows Azure 诊断错误 :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5712035/