다음을 통해 공유


DiagnosticDataBufferConfiguration.BufferQuotaInMB Property

 

Gets or sets the maximum amount of file system storage available to the specified data buffer.

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

Syntax

public int BufferQuotaInMB { get; set; }
public:
property int BufferQuotaInMB {
    int get();
    void set(int value);
}
member BufferQuotaInMB : int with get, set
Public Property BufferQuotaInMB As Integer

Property Value

Type: System.Int32

Type: System.Int32

Returns Int32.

Remarks

The BufferQuotaInMB property sets the amount of local storage to allocate for a specified data buffer. You can specify the value of this property when configuring any of the diagnostic sources for a diagnostic monitor.

By default, the BufferQuotaInMB property is set to 0 for each data buffer. Diagnostic data will be written to each data buffer until the OverallQuotaInMB limit is reached unless you set a value for this property.

If you set this property and the quota is reached, the oldest data is deleted as new data is added. This deletion policy also applies if you have configured a transfer interval for the buffer. After the transfer has occurred, the data remains in local storage and will be deleted per the above policy.

Example

The following code snippet remotely configures a performance counter log buffer to 2GB for all instances of a specifc role.

// 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 (https://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 (https://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();

   // Use 30 seconds for the performance counter sample rate.
   TimeSpan perfSampleRate = TimeSpan.FromSeconds(30.0);

   // Add a performance counter for processor time.
   diagnosticConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
   {
      CounterSpecifier = @"\Processor(_Total)\% Processor Time",
         SampleRate = perfSampleRate
   });

   // Set the performance counter buffer to 2GB.
   diagnosticConfiguration.PerformanceCounters.BufferQuotaInMB = 2048;
   roleInstance.SetCurrentConfiguration(diagnosticConfiguration);
}

Warning

This API is not supported in Azure SDK versions 2.5 and higher. Instead, use the diagnostics.wadcfg XML configuration file. For more information, see Collect Logging Data by Using Azure Diagnostics.

See Also

DiagnosticDataBufferConfiguration Class
Microsoft.WindowsAzure.Diagnostics Namespace

Return to top