问题
I am writing a new Cloud Service in .NET using Azure SDK 2.5. I'm aware that there have been some significant changes to diagnostics with the 2.5 SDK rekesae.
Where I am getting conflicting information is whether or not I can still use Azure Diagnostics to capture Trace.* output to WADLogsTable
in Azure Table Storage?
I'm aware that I can use ETW as an alternative, but that's now what I'm asking for.
According to this article I can still use Trace to capture my logs with Azure Diagnostics 1.3 - which I understand has shipped with SDK 2.5.
Unfortunately I cannot get it to work.
The app.config of my worker role looks like:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Throughout the code in my worker role I have tracing code that looks like this:
Trace.TraceInformation("Something happened");
My public diagnostics.wadcfg file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>mystorageAccount</StorageAccount>
</PublicConfig>
I have used this file to configure the diagnostics service extension using the PowerShell command:
Set-AzureServiceDiagnosticsExtension
No WADLogsTable is ever created. If I enable other diagnostics services such as Perf Counter then the relevant tables (WADPerformanceCountersTable) are created and populated.
I am using:
- Visual Studio 2012
- .NET 4.5.1
- Azure Powershell (latest v from Web Platform Installer)
- Azure SDK 2.5
Can anyone put me out of my misery? Many Thanks
回答1:
How are you deploying? On the same setup (VS2012, Azure 2.5 SDK), I only saw the WADLogsTable get created using the Visual Studio "Publish" wizard, which apparently configures the diagnostics extension for you. See:
https://msdn.microsoft.com/en-us/library/azure/dn873976.aspx
Diagnostics configuration must be applied separately after deployment - Because Azure SDK version 2.5 uses the extension model, the diagnostics extension and configuration are no longer part of the deployment package and must be applied separately after the deployment. Visual Studio will apply the extension and configuration for you when you use the Publish wizard to deploy your application [...]
I wasn't able to get the PowerShell cmdlets to work (didn't put much effort into that, honestly) but as a workaround, when I deployed using the VS "Publish" wizard, the WADLogsTable was created and I could see my logs flowing. This didn't happen when I packaged and uploaded through the Azure Portal.
It may be this way for the foreseeable future; the situation doesn't seem to have changed in the 2.6 SDK (though they fixed a lot of the irksomeness with diagnostics in 2.5): https://msdn.microsoft.com/en-us/library/azure/dn186185.aspx
回答2:
I just created a default worker role that is producing trace logs and I noticed one difference in the public config
<?xml version="1.0" encoding="utf-8"?>
<PublicConfig xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<WadCfg>
<DiagnosticMonitorConfiguration overallQuotaInMB="4096">
<WindowsEventLog scheduledTransferPeriod="PT1M">
<DataSource name="Application!*" />
</WindowsEventLog>
<Logs scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Information" />
</DiagnosticMonitorConfiguration>
</WadCfg>
<StorageAccount>mystorageAccount</StorageAccount>
</PublicConfig>
来源:https://stackoverflow.com/questions/29001243/azure-sdk-trace-information-and-wadlogstable