1
votes

According to Microsoft Azure Diagnostics Part 4: Custom Logging Components and Azure Diagnostics 1.3 Changes:

Azure Diagnostics 1.3 does not support System.Diagnostic.Trace logs. Instead, you are to use EventSource. The System.Diagnostic.Trace logging statements can still be used in the emulated environment to write trace/debug statements to the Azure Compute Emulator console.

I have been searching for a sample of how to use the System.Diagnostics ETW (Event Tracing for Windows) framework in a simple way within Azure much like one would use logging frameworks like log4Net. Is there an easy way to wrap ETW into a log appender within log4Net in order that statements like the below can be written within an Azure solution.

Log.Info("My info logging statement.")

This shouldn't be difficult but I cannot find any simple samples out there for something like this.

1

1 Answers

1
votes

That article stating the WAD 1.3 doesn't support Trace statements is outdated and no longer correct. When the new version of WAD was introduced it initially did not include support for System.Diagnostics.Trace, but this has since been resolved and should work just fine. The key thing to remember is that you will need the 2.5 version of Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener registered as a trace listener. The easiest way is to put the following into your web.config (for IIS code) or app.config (for Worker Roles or code in WaIISHost.exe):

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


If you want to use ETW traces you can check out the sample at http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/.