Exportieren (0) Drucken
Alle erweitern

DirectoryConfiguration-Klasse

Represents the configuration of a directory to which file-based logs are written.

Namespace: Microsoft.WindowsAzure.Diagnostics
Assembly: Microsoft.WindowsAzure.Diagnostics (in microsoft.windowsazure.diagnostics.dll)

'Usage
Dim instance As DirectoryConfiguration

public class DirectoryConfiguration
public class DirectoryConfiguration
public class DirectoryConfiguration

The DirectoryConfiguration class provides properties to configure a directory for storing logs and diagnostic data. By default, directories for IIS logs (for web roles only), failed request logs, and crash dumps are automatically configured. You can also configure additional custom logs.

The DirectoryConfiguration object is used by your role instance’s DiagnosticMonitorConfiguration. Specifically, you add the DirectoryConfiguration to the DataSources collection of a DiagnosticMonitorConfiguration class.

Example

The following code snippet demonstrates how to use DirectoryConfiguration in the context of a role’s OnStart() method. This method creates a new DirectoryConfiguration object, specifies the container name for our custom log directory, adds the configuration to our DiagnosticMonitorConfiguration object, and starts the DiagnosticMonitor with the new configuration.

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

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

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

    // Add the directory size quota.
    directoryConfiguration.DirectoryQuotaInMB = 2048;

    // Add the log path for the role using RoleEnvironment.GetLocalResource().
    directoryConfiguration.Path = RoleEnvironment.GetLocalResource("MyCustomLogs").RootPath;

    // Add the directoryConfiguration to the Directories collection.
    diagnosticConfiguration.Directories.DataSources.Add(directoryConfiguration);

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

The following snippet from a ServiceConfiguration.cscfg file defines the MyCustomLogs directory.

<LocalResources>
    <LocalStorage name="MyCustomLogs" sizeInMB="8192" cleanOnRoleRecycle="false"/>
</LocalResources>

System.Object
  Microsoft.WindowsAzure.Diagnostics.DirectoryConfiguration

Alle öffentlichen statischen (freigegebenen in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Entwicklungsplattformen

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 und Windows 2000

Zielplattformen

Community-Beiträge

Anzeigen:
© 2015 Microsoft