在 Azure 存储中存储和查看诊断数据Store and view diagnostic data in Azure Storage

诊断数据不会永久存储,除非将其传输到 Azure 存储模拟器或 Azure 存储。Diagnostic data is not permanently stored unless you transfer it to the Azure Storage Emulator or to Azure Storage. 一旦位于存储空间中,诊断数据就可以使用提供的工具之一进行查看。Once in storage, it can be viewed with one of several available tools.

指定存储帐户Specify a storage account

指定要在 ServiceConfiguration.cscfg 文件中使用的存储帐户。You specify the storage account that you want to use in the ServiceConfiguration.cscfg file. 帐户信息被定义为配置设置中的连接字符串。The account information is defined as a connection string in a configuration setting. 以下示例显示的是在 Visual Studio 中针对新的云服务项目创建的默认连接字符串:The following example shows the default connection string created for a new Cloud Service project in Visual Studio:

    <ConfigurationSettings>
       <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>

可以更改此连接字符串,为 Azure 存储帐户提供帐户信息。You can change this connection string to provide account information for an Azure storage account.

根据所要收集的诊断数据的类型,Azure 诊断使用 Blob 服务或表服务。Depending on the type of diagnostic data that is being collected, Azure Diagnostics uses either the Blob service or the Table service. 下表显示保留的数据源及其格式。The following table shows the data sources that are persisted and their format.

数据源Data source 存储格式Storage format
Azure 日志Azure logs Table
IIS 7.0 日志IIS 7.0 logs BlobBlob
Azure 诊断基础结构日志Azure Diagnostics infrastructure logs Table
失败请求跟踪日志Failed Request Trace logs BlobBlob
Windows 事件日志Windows Event logs Table
性能计数器Performance counters Table
故障转储Crash dumps BlobBlob
自定义错误日志Custom error logs BlobBlob

传输诊断数据Transfer diagnostic data

对于 SDK 2.5 及更高版本,可以通过配置文件来请求传输诊断数据。For SDK 2.5 and later, the request to transfer diagnostic data can occur through the configuration file. 可以根据配置中的指定,按计划的时间间隔来传输诊断数据。You can transfer diagnostic data at scheduled intervals as specified in the configuration.

对于 SDK 2.4 及更低版本,可以请求通过配置文件来传输诊断数据,也可以通过编程方式来进行。For SDK 2.4 and previous you can request to transfer the diagnostic data through the configuration file as well as programmatically. 编程方式还可以进行按需传输。The programmatic approach also allows you to do on-demand transfers.

重要

将诊断数据传输到 Azure 存储帐户时会产生费用,具体取决于诊断数据所使用的存储资源。When you transfer diagnostic data to an Azure storage account, you incur costs for the storage resources that your diagnostic data uses.

存储诊断数据Store diagnostic data

日志数据存储在使用以下名称的 Blob 或表存储中:Log data is stored in either Blob or Table storage with the following names:

Tables

  • WadLogsTable - 使用跟踪侦听器以代码编写的日志。WadLogsTable - Logs written in code using the trace listener.
  • WADDiagnosticInfrastructureLogsTable - 诊断监视器和配置更改。WADDiagnosticInfrastructureLogsTable - Diagnostic monitor and configuration changes.
  • WADDirectoriesTable - 诊断监视器监视的目录。WADDirectoriesTable - Directories that the diagnostic monitor is monitoring. 这包括 IIS 日志、IIS 失败请求日志和自定义目录。This includes IIS logs, IIS failed request logs, and custom directories. 在“容器”字段中指定 blob 日志文件的位置,在 RelativePath 字段中指定 blob 的名称。The location of the blob log file is specified in the Container field and the name of the blob is in the RelativePath field. AbsolutePath 字段指示文件的位置和名称,就像文件是存在于 Azure 虚拟机上一样。The AbsolutePath field indicates the location and name of the file as it existed on the Azure virtual machine.
  • WADPerformanceCountersTable - 性能计数器。WADPerformanceCountersTable - Performance counters.
  • WADWindowsEventLogsTable - Windows 事件日志。WADWindowsEventLogsTable - Windows Event logs.

BlobBlobs

  • wad-control-container -(仅适用于 SDK 2.4 及更低版本)包含用于控制 Azure 诊断的 XML 配置文件。wad-control-container - (Only for SDK 2.4 and previous) Contains the XML configuration files that controls the Azure diagnostics .
  • wad-iis-failedreqlogfiles - 包含 IIS 失败请求日志中的信息。wad-iis-failedreqlogfiles - Contains information from IIS Failed Request logs.
  • wad-iis-logfiles - 包含有关 IIS 日志的信息。wad-iis-logfiles - Contains information about IIS logs.
  • "custom" - 自定义容器,基于配置由诊断监视器监视的目录。"custom" - A custom container based on configuring directories that are monitored by the diagnostic monitor. 此 blob 容器的名称会在 WADDirectoriesTable 中指定。The name of this blob container will be specified in WADDirectoriesTable.

用于查看诊断数据的工具Tools to view diagnostic data

将数据传输到存储空间以后,可以使用多个工具来查看这些数据。Several tools are available to view the data after it is transferred to storage. 例如:For example:

  • Visual Studio 中的服务器资源管理器 - 如果安装了 Azure Tools for Microsoft Visual Studio,则可以在服务器资源管理器中使用“Azure 存储”节点从 Azure 存储帐户查看只读 Blob 和表数据。Server Explorer in Visual Studio - If you have installed the Azure Tools for Microsoft Visual Studio, you can use the Azure Storage node in Server Explorer to view read-only blob and table data from your Azure storage accounts. 既可以从本地存储模拟器帐户显示数据,也可以从为 Azure 创建的存储帐户显示数据。You can display data from your local storage emulator account and also from storage accounts you have created for Azure. 有关详细信息,请参阅使用服务器资源管理器浏览和管理存储资源For more information, see Browsing and Managing Storage Resources with Server Explorer.
  • Azure 存储资源管理器是一款独立应用,可用于在 Windows、OSX 和 Linux 上轻松处理 Azure 存储数据。Azure Storage Explorer is a standalone app that enables you to easily work with Azure Storage data on Windows, OSX, and Linux.
  • Azure Management Studio 包括 Azure 诊断管理器,该诊断管理器用于查看、下载和管理在 Azure 上运行的应用程序收集的诊断数据。Azure Management Studio includes Azure Diagnostics Manager which allows you to view, download and manage the diagnostics data collected by the applications running on Azure.

后续步骤Next Steps

使用 Azure 诊断跟踪云服务应用程序中的流Trace the flow in a Cloud Services application with Azure Diagnostics