Windows Azure 诊断错误:

发布于 2024-11-02 05:10:21 字数 1997 浏览 1 评论 0原文

我正在使用 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,但这不起作用。 我希望应用程序能够在部署环境中运行。 如果有人有任何想法来解决这个问题,请回复我。

提前致谢。

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

try

        {

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



        }

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天煞孤星 2024-11-09 05:10:21

问题似乎您没有更改“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”的连接字符串。您可以在 Web 角色项目或服务配置文件的设置中更改此设置。将其设置为您的帐户名和密钥。我通常使用构建脚本来执行此操作,以便在投入生产时可以更改它。您可以查看帖子 此处和代码此处

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文