次の方法で共有


DiagnosticMonitor Class

 

Represents the diagnostic monitor for a role instance in Windows Azure.

Namespace:   Microsoft.WindowsAzure.Diagnostics
Assembly:  Microsoft.WindowsAzure.Diagnostics (in Microsoft.WindowsAzure.Diagnostics.dll)

Inheritance Hierarchy

System.Object
  Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor

Syntax

public class DiagnosticMonitor
public ref class DiagnosticMonitor 
type DiagnosticMonitor = class end
Public Class DiagnosticMonitor

Properties

Name Description
System_CAPS_pubpropertySystem_CAPS_static AllowInsecureRemoteConnections

Obsolete.This API is now obsolete. Specifies that the diagnostic monitor may use non-secure (HTTP) connections to communicate with the storage account.

System_CAPS_pubproperty LocalDataDirectory

Gets the local directory where state information for the diagnostic monitor is stored.

Methods

Name Description
System_CAPS_pubmethod Equals(Object)

(Inherited from Object.)

System_CAPS_protmethod Finalize()

(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_static GetDefaultInitialConfiguration()

Returns the default initial diagnostic monitor configuration for the current role instance.

System_CAPS_pubmethod GetHashCode()

(Inherited from Object.)

System_CAPS_pubmethod GetType()

(Inherited from Object.)

System_CAPS_protmethod MemberwiseClone()

(Inherited from Object.)

System_CAPS_pubmethod Shutdown()

Stops the diagnostic monitor.

System_CAPS_pubmethodSystem_CAPS_static Start(String)

Starts a diagnostic monitor using the specified storage account and default diagnostic monitor configuration.

System_CAPS_pubmethodSystem_CAPS_static Start(String, DiagnosticMonitorConfiguration)

Starts a diagnostic monitor using the specified storage account and diagnostic monitor configuration.

System_CAPS_pubmethodSystem_CAPS_static StartWithConnectionString(String, DiagnosticMonitorConfiguration)

Starts a diagnostic monitor using the specified connection string and diagnostic monitor configuration.

System_CAPS_pubmethod ToString()

(Inherited from Object.)

System_CAPS_pubmethod UpdateStorageAccount(String)

Updates the storage account information for the current diagnostic monitor.

Remarks

The DiagnosticMonitor class provides methods and properties that enable collection of diagnostic data for a role instance in Windows Azure. DiagnosticMonitor is a singleton, so each role instance has only one instantiated DiagnosticMonitor.

The default configuration of DiagnosticMonitor collects Windows Azure logs and Windows Azure Diagnostic Infrastructure logs for web and worker roles. The default configuration will also collect IIS logs for web roles only. These settings are included in the DiagnosticMonitorConfiguration object returned by the GetDefaultInitialConfiguration method. You can configure additional logging options by creating a DiagnosticMonitorConfiguration object, specifying the diagnostics data you want by setting the properties of that object, and passing the object as a parameter to the Start method.

You can specify a Windows Azure Storage account for the DiagnosticMonitor by including a connection string as an input parameter when calling the Start or StartWithConnectionString method.

Note

If you call the Start method using a misconfigured connection string, the DiagnosticMonitor will not start with your role instance.

To use DiagnosticMonitor, you must perform the following steps:

  1. Import the Diagnostics module into your application by modifying the ServiceDefinition.csdef file to include the following lines:

    <Imports>
        <Import moduleName=”Diagnostics” />
    </Imports>
    
  2. Specify a storage location where the diagnostics data will be transferred, either a Windows Azure storage account or the local storage emulator. For example, modify your ServiceConfiguration.cscfg file to include the following lines if you want to store diagnostics data in the storage emulator:

    <ConfigurationSettings>
         <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
    
  3. Make sure that your project includes a reference to Microsoft.WindowsAzure.Diagnostics.dll, and optionally includes a using Microsoft.WindowsAzure.Diagnostics; directive in each code file that uses the DiagnosticMonitor.

After the DiagnosticMonitor has been configured, if you want to start collecting the default logs, you do not need to call the Start method. Roles that have imported the Diagnostics module, specified a data storage location, and referenced the .dll will automatically start the DiagnosticMonitor using the default configuration when the role initializes.

However, if you want to specify a custom logging configuration, you must call the M:Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitor.Start(Microsoft.WindowsAzure.CloudStorageAccount,Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorConfiguration) method and supply the storage account and your custom DiagnosticMonitorConfiguration object as parameters to the method. This call is shown in the following example where dmConfig is a custom DiagnosticMonitorConfiguration object:

DiagnosticMonitor.Start(“Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString”, dmConfig)

Warning

This API is not supported in Azure SDK versions 2.5 and higher. Instead, use the diagnostics.wadcfg XML configuration file. For more information, see Collect Logging Data by Using Azure Diagnostics.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Microsoft.WindowsAzure.Diagnostics Namespace

Return to top