Logs 属性
此文章由机器翻译。 将光标移到文章的句子上,以查看原文。 更多信息。

DiagnosticMonitorConfiguration.Logs 属性


获取或设置 Microsoft Azure 跟踪侦听器捕获的基本 Microsoft Azure 日志的缓冲区配置。

命名空间:   Microsoft.WindowsAzure.Diagnostics
程序集:  Microsoft.WindowsAzure.Diagnostics(Microsoft.WindowsAzure.Diagnostics.dll 中)

Diagnostics.wadcfg 文件用于在应用程序中配置诊断。 有关如何配置的详细信息您 diagnostics.wadcfg 文件,请参阅 Enabling Diagnostics in Windows Azure 你的应用程序在 Microsoft Azure 中运行后,你可以同时使用 DiagnosticMonitorConfiguration 类和 RoleInstanceDiagnosticManager 类来远程更改应用程序诊断配置。

使用 Logs 属性可以指定用于 Microsoft Azure 日志的 BasicLogsBufferConfiguration 数据缓冲区。 此属性可设置 ScheduledTransferLogLevelFilter 属性,以及默认的数据缓冲区属性: BufferQuotaInMBScheduledTransferPeriod


以下代码段将获取角色中每个实例的诊断监视器配置,指定 Microsoft Azure 日志的日志配置,然后设置更新的配置。

// Get the connection string. It's recommended that you store the connection string in your web.config or app.config file. // Use the ConfigurationManager type to retrieve your storage connection string.  You can find the account name and key in // the Windows Azure Management Portal (http://manage.windowsazure.com). //string connectionString = "DefaultEndpointsProtocol=https;AccountName=<AccountName>;AccountKey=<AccountKey>"; string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString; // The deployment ID and role name for your application can be obtained from the // Windows Azure Management Portal (http://manage.windowsazure.com). See your // application dashboard under Cloud Services. string deploymentID = "e2ab8b6667644666ba627bdf6f5e4daa"; string roleName = "WebRole1"; // Get the DeploymentDiagnosticManager object for your deployment. DeploymentDiagnosticManager diagManager = new DeploymentDiagnosticManager(connectionString, deploymentID); // Get the RoleInstanceDiagnosticManager objects for each instance of your role. IEnumerable<RoleInstanceDiagnosticManager> instanceManagers = diagManager.GetRoleInstanceDiagnosticManagersForRole(roleName); // Iterate through the role instances and update the configuration. foreach (RoleInstanceDiagnosticManager roleInstance in instanceManagers) { DiagnosticMonitorConfiguration diagnosticConfiguration = roleInstance.GetCurrentConfiguration(); // Filter the logs so that only error-level logs are transferred to persistent storage. diagnosticConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Error; // Schedule a transfer period of 30 minutes. diagnosticConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0); // Specify a buffer quota of 1GB. diagnosticConfiguration.Logs.BufferQuotaInMB = 1024; // Set the configuration. roleInstance.SetCurrentConfiguration(diagnosticConfiguration); }

Azure SDK 2.5 和更高版本不支持此 API。 请改用 diagnostics.wadcfg XML 配置文件。 有关详细信息,请参阅 使用 Azure 诊断收集日志记录数据

© 2015 Microsoft