本主題尚未接受評分 - 為這個主題評分

DirectoryConfiguration 類別

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

命名空間: Microsoft.WindowsAzure.Diagnostics
組件: Microsoft.WindowsAzure.Diagnostics (在 microsoft.windowsazure.diagnostics.dll 中)
'用途
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
任何這個類型的公用靜態 (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。 並非所有的執行個體成員都是安全執行緒。

開發平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003、Windows Server 2008 和 Windows 2000

目標平台

本文對您有任何幫助嗎?
(剩餘 1500 個字元)

社群新增項目

© 2013 Microsoft. 著作權所有,並保留一切權利。
facebook page visit twitter rss feed newsletter