开发者

Windows Azure Diagnostics Error:

I am working with Windows Azure Diagnostics. I add the below code in Webrol.cs

try

        {

            string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionStr开发者_如何学Cing";

            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");



        }

and the remaining neccesary things in Web.config and the connection string in the .cscfg file. Now I am able to log the Diagnostics in the from the Development environment using the Deployment Storage. But when i host the same application in Cloud I am not able to log the Diagnostics. I am getting an error like

"500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed."

I tried by changing Copy local to true for the namespaces, but that doesn't work. I want the application to work in the deployment environment. If anyone have any idea to resolve this please reply me.

Thanks in advance.


The problem looks like you are not changing the connection string for "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString". You can change this in the settings for the web role project or you service configuration file. Set it to your account name and key. I normally do this with a build script so I can change this when I push to production. You can check out the post here and the code here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜