Esporta (0) Stampa
Espandi tutto

Classe DirectoryConfiguration

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

Spazio dei nomi: Microsoft.WindowsAzure.Diagnostics
Assembly: Microsoft.WindowsAzure.Diagnostics (in microsoft.windowsazure.diagnostics.dll)

'Utilizzo
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

Tutti i membri statici pubblici (Shared in Visual Basic) di questo tipo sono thread-safe. I membri di istanza non sono garantiti come thread-safe.

Piattaforme di sviluppo

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

Piattaforme di destinazione

Aggiunte alla community

Microsoft sta conducendo un sondaggio in linea per comprendere l'opinione degli utenti in merito al sito Web di MSDN. Se si sceglie di partecipare, quando si lascia il sito Web di MSDN verrà visualizzato il sondaggio in linea.

Si desidera partecipare?
Mostra:
© 2015 Microsoft