WindowsEventLog 屬性
本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

DiagnosticMonitorConfiguration.WindowsEventLog 屬性

 

取得或設定 Windows 事件記錄檔的緩衝區組態。

命名空間:   Microsoft.WindowsAzure.Diagnostics
組件:  Microsoft.WindowsAzure.Diagnostics (在 Microsoft.WindowsAzure.Diagnostics.dll 中)

Diagnostics.wadcfg 檔案用來在應用程式中設定診斷功能。 如需有關如何設定您 diagnostics.wadcfg 檔案中,請參閱 Enabling Diagnostics in Windows Azure 一旦您的應用程式 Windows Azure 中執行,您可以使用 DiagnosticMonitorConfiguration 類別連同 RoleInstanceDiagnosticManager 類別來從遠端變更您的應用程式診斷組態。

WindowsEventLog 屬性用來指定 WindowsEventLogsBufferConfiguration 用於 Windows 事件記錄的資料緩衝區。 此屬性可讓您加入至事件記錄檔來源 DataSources 每個您想要擷取的事件類型的集合。 您也可以指定 ScheduledTransferLogLevelFilter LogLevel 列舉型別將每個記錄檔的嚴重性層級設定為傳輸至永續性的儲存體和預設資料緩衝區屬性: DiagnosticDataBufferConfigurationScheduledTransferPeriod。 

Example

下列程式碼片段會取得角色中的每個執行個體的診斷監視器組態、指定 Windows 事件的組態,並設定新的組態。

// 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(); // Add Application logs to the configuration. diagnosticConfiguration.WindowsEventLog.DataSources.Add("Application!*"); // Filter the logs so that only error-level logs are transferred to persistent storage. diagnosticConfiguration.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Error; // Schedule a transfer period of 30 minutes. diagnosticConfiguration.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0); // Set the configuration. roleInstance.SetCurrentConfiguration(diagnosticConfiguration); }
System_CAPS_warning警告

這個 API 不支援在 Azure 2.5 和更新版本的 SDK 版本。 請改用 diagnostics.wadcfg XML 組態檔。 如需詳細資訊,請參閱 收集記錄資料使用 Azure 診斷程式

回到頁首
顯示:
© 2016 Microsoft