SALES: 1-800-867-1380

CrashDumps.EnableCollectionToDirectory Method

Updated: June 6, 2012

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)

[EditorBrowsableAttribute(EditorBrowsableState::Advanced)] 
public:
static void EnableCollectionToDirectory (
	String^ directory, 
	bool enableFullDumps
)

Parameters

directory

Type: System.String

The absolute path to the local directory.

enableFullDumps

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.

Example

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.csdef

<ServiceDefinition name="MyServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole1" vmsize="Small"> 
   <LocalResources>
      <LocalStorage name="MyCustomCrashDumpsLocation" sizeInMB="1024" cleanOnRoleRecycle="false" />
   </LocalResources>
</WebRole>
</ServiceDefinition>

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.

WorkerRole.cs

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.
    diagnosticConfiguration.Directories.DataSources.Add(directoryConfiguration);

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

    return base.OnStart();
}


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 and Windows Server 2008

Target Platforms

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft