CrashDumps.EnableCollectionToDirectory Method (String, Boolean)


Enables collection mini crash dumps or full crash dumps for a role instance to the specified directory.

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

public static void EnableCollectionToDirectory(
	string directory,
	bool enableFullDumps


Type: System.String

Type: System.String

The absolute path to the local directory.

Type: System.Boolean

Type: System.Boolean

If true, collects full crash dumps. If false, collects mini crash dumps.

When you enable collection of crash dumps, the resulting data is written locally to the specified directory.

When crash dump data is transferred to persistent storage, it is stored to the wad-crash-dumps Blob container. You can specify the transfer interval of the specified directory by setting the ScheduledTransferPeriod property of Directories.


You can create a local resource for your hosted service by adding a LocalResources element to the ServiceDefinition.csdef file. For example, the following sample creates a local resource called MyCustomCrashDumpsLocation:


<ServiceDefinition name="MyServiceName" xmlns="">
<WebRole name="WebRole1" vmsize="Small"> 
      <LocalStorage name="MyCustomCrashDumpsLocation" sizeInMB="1024" cleanOnRoleRecycle="false" />

The following code snippet creates a DiagnosticMonitorConfiguration object, enables full crash dump collection to the MyCustomCrashDumpsLocation resource, adds the path to the list of directories that are monitored for diagnostic data, and sets a transfer interval of 30 minutes.


public override bool OnStart()
    // Get the default initial configuration for DiagnosticMonitor.
    DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

    // Create a custom logging path for crash dumps.
    string customCrashDumpsPath = RoleEnvironment.GetLocalResource("MyCustomCrashDumpsLocation").RootPath;

    // Enable full crash dump collection to the custom path.
    CrashDumps.EnableCollectionToDirectory(customCrashDumpsPath, true);

    // Create a new DirectoryConfiguration object.
    DirectoryConfiguration directoryConfiguration = new DirectoryConfiguration();

    // Add the name for the blob container in Windows Azure storage.
    directoryConfiguration.Container = "wad-crash-dumps";

    // Add the directory size quota.
    directoryConfiguration.DirectoryQuotaInMB = RoleEnvironment.GetLocalResource("MyCustomCrashDumpsLocation").MaximumSizeInMegabytes;

    // Add the crash dumps path.
    directoryConfiguration.Path = customCrashDumpsPath;

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

    // Add the directoryConfiguration to the Directories collection.

    // Start the DiagnosticMonitor using the diagnosticConfig and our connection string.
    DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);

    return base.OnStart();


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.

Return to top