1

I'm unable to get Azure Diagnostics to spit out any of my Trace messages - even in the near-as-is VS2012 project template. Here is what I did:

  1. In an empty VS2012, created a new Cloud project (called it "Azure.Diag")
  2. In the wizards next step, added the default template for "WCF Service Web Role" (called it "WCFService.WebRole")
  3. Editted Web.Config to enable Diagnostics (details below)
  4. Editted WebRole.cs to spit a Diagnostic Trace message (details below)
  5. Ran it locally in Azure Emulator (ServiceConfiguration.Local.cscfg: Diagnostics.ConnectionString is "UseDevelopmentStorage=true")
  6. Look at C:\Users\<Username>\AppData\Local\dftmp\Resources\<Instance GUID>\directory\WCFService.WebRole.svclog => see nothing!
  7. There is also nothing in the Local Storage Blog either (not surprising given the folder before move-to-blob is empty)

How can I get this working? I'm trying to avoid my own handwritten .txt logs to leverage the in built trace listener framework (and parsing tools).

WebRole.cs

using System.Diagnostics;

namespace WCFService.WebRole
{
    public class WebRole : RoleEntryPoint
    {
        public override bool OnStart()
        {
            // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config  
            DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
            diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());

            string message = "Houston, tracing is broken!";
            Trace.TraceError(message);
            Trace.TraceInformation(message);
            Trace.TraceWarning(message);
            Trace.WriteLine(message);

            return base.OnStart();
        }
    }
}

Web.Config:

I used the standard template one but uncommented the top portion (had to merge the two system.diagnostic portions to avoid HTTP 500)

  <system.diagnostics>     
    <sharedListeners>
      <add name="AzureLocalStorage" type="WCFService.WebRole.AzureLocalStorageTraceListener, WCFService.WebRole" />
    </sharedListeners>
    <!--<sources>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
    </sources>-->
    <trace autoflush="true">
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
4

0 回答 0