2011-04-19 106 views
1

我正在使用Windows Azure诊断程序。我添加下面的代码在Webrol.csWindows Azure诊断错误:

尝试

 { 

      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中的剩余neccesary东西,在.cscfg文件的连接字符串。 现在我可以使用部署存储从开发环境中记录诊断。但是,当我在云中托管相同的应用程序时,我无法记录诊断。我遇到如下错误:

“500 - 内部服务器错误 您正在查找的资源存在问题,并且无法显示。”

我试图通过更改名称空间的复制本地为true,但这不起作用。 我希望应用程序在部署环境中工作。 如果有人有任何想法解决这个问题,请回复我。

在此先感谢。

+1

部署到云时,是否将“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”的值设置为实际存储帐户的连接字符串? – knightpfhor 2011-04-19 20:14:06

回答

0

问题看起来像你没有改变“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”的连接字符串。您可以在Web角色项目或服务配置文件的设置中更改此设置。将其设置为您的帐户名称和密钥。我通常使用构建脚本来做到这一点,所以我可以在推进生产时改变这一点。您可以查看帖子here和代码here