CrashDumps.EnableCollectionToDirectory Method
Assembly: Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)
[EditorBrowsableAttribute(EditorBrowsableState.Advanced)] public static void EnableCollectionToDirectory ( string directory, bool enableFullDumps )
/** @attribute EditorBrowsableAttribute(EditorBrowsableState.Advanced) */ public static void EnableCollectionToDirectory ( String directory, boolean enableFullDumps )
EditorBrowsableAttribute(EditorBrowsableState.Advanced) public static function EnableCollectionToDirectory ( directory : String, enableFullDumps : boolean )
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, 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 CrashDumps.
string customCrashDumpsPath = RoleEnvironment.GetLocalResource("MyCustomCrashDumpsLocation").RootPath;
// Enable full crash dump collection to the custom path.
CrashDumps.EnableCollectionToDirectory(customCrashDumpsPath, true);
// Schedule a transfer period of 30 minutes.
diagnosticConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(30.0);
// Start the DiagnosticMonitor using the diagnosticConfig and our connection string.
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);
return base.OnStart();
}
Development Platforms
Windows Vista, Windows 7 and Windows Server 2008Target Platforms