Eksportuj (0) Drukuj
Rozwiń wszystko
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

DiagnosticMonitorConfiguration.DiagnosticInfrastructureLogs Property

Updated: December 6, 2013

Gets or sets the buffer configuration for the logs generated by the underlying diagnostics infrastructure. The diagnostic infrastructure logs are useful for troubleshooting the diagnostics system itself.

Namespace: Microsoft.WindowsAzure.Diagnostics
Assembly: Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)

[EditorBrowsableAttribute(EditorBrowsableState.Advanced)] 
public BasicLogsBufferConfiguration DiagnosticInfrastructureLogs { get; set; }

Property Value

Type: Microsoft.WindowsAzure.Diagnostics.BasicLogsBufferConfiguration

Returns BasicLogsBufferConfiguration.

The diagnostics.wadcfg file is used to configure diagnostics in your application. For more information on how to configure your diagnostics.wadcfg file, see Enabling Diagnostics in Windows Azure. Once your application is running in Windows Azure, you can use the DiagnosticMonitorConfiguration class along with the RoleInstanceDiagnosticManager class to remotely change your application’s diagnostics configuration.

The DiagnosticInfrastructureLogs property is used to specify the BasicLogsBufferConfiguration data buffer that is used for logging the diagnostic infrastructure itself. This property enables you to set the ScheduledTransferLogLevelFilter property, as well as the default data buffer properties: BufferQuotaInMB and ScheduledTransferPeriod.

Example

The following code snippet gets the diagnostics configuration for each instance in a specific role, changes the configuration for diagnostic infrastructure logs, then sets the new configuration.

// 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.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Error;

   // Schedule a transfer period of 30 minutes.
   diagnosticConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0);

   // Specify a buffer quota.
   diagnosticConfiguration.DiagnosticInfrastructureLogs.BufferQuotaInMB = 1024;

   roleInstance.SetCurrentConfiguration(diagnosticConfiguration);
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Target Platforms

Zawartość społeczności

Dodaj
Pokaż:
© 2014 Microsoft