Share via

LogLevel Enumeration


Enumeration of a standard set of logging levels.

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


public enum LogLevel
public enum class LogLevel
type LogLevel
Public Enumeration LogLevel


Member name Description

Value: 1. Indicates logs for a critical alert.


Value: 2. Indicates logs for an error.


Value: 4. Indicates logs for an informational message.


Value: 0. Indicates logs at all levels.


Value: 5. Indicates logs at all levels.


Value: 3. Indicates logs for a warning.


The LogLevel enumeration is used to specify a logging level for the ScheduledTransferLogLevelFilter property of a log data buffer. When you specify a LogLevel, all events greater than and equal to the specified severity are transferred to persistent storage. For example, if you specify LogLevel = Warning, Error and Critical logs will also be transferred to persistent storage.

When this property is set to Undefined, no filter is applied and all logging events at all levels are transferred.


The following code snippet will transfer only error-level Windows Event logs from local storage to persistent storage every 25 minutes.

 // 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 (
//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 ( 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 25 minutes.
                  diagnosticConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(25.0);

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



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

Microsoft.WindowsAzure.Diagnostics Namespace

Return to top