1

in my Azure app I have Trace.WriteLine() calls sprinkled about to track what the application is doing.

What is stumping me is that some of these make it to the log and others don't. For example, this snippet of code from my worker role OnStart() method:

Trace.WriteLine("WorkerRole: creating storage tables", "Information");
CloudStorageAccount account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
CloudTableClient tableClient = account.CreateCloudTableClient();
if (tableClient.CreateTableIfNotExist("Devices")) {
    Trace.WriteLine("WorkerRole.OnStart: Devices table created", "Information");
}else{
    Trace.WriteLine("WorkerRole.OnStart: Devices table not created. Already exists?", "Information");
}

The first Trace gets logged. Neither of the Trace calls in the if statement gutted logged. Then a Trace method in a subsequently executing method does get logged.

Any ideas?

onnoweb
  • 3,038
  • 22
  • 29
  • Perhaps something threw an exception behind your back? – Jeremy McGee Sep 22 '11 at 11:01
  • I am thinking that too although I have try-catch wrappers around most pieces that could throw. It also seems that some of the traces do get logged but just many minutes later. – onnoweb Sep 22 '11 at 13:25
  • I posted what may or may not be a duplicate of this problem here: http://stackoverflow.com/questions/7522762/why-doesnt-windows-azure-diagnostics-reliably-log – Jaxidian Sep 23 '11 at 16:35
  • In my scenario, I can assure you that it's not an exception being thrown causing problems as I can reproduce it running locally while debugging the code. The `Trace` will output to the Output window just fine but it's a coin-flip whether or not it'll show up in my Azure table. – Jaxidian Sep 23 '11 at 16:36

1 Answers1

0

In your OnStart method for your role, are you adjusting the DiagnosticMonitorConfiguration? By default, trace logs aren't transfered to storage unless you tell it to:

  public override bool OnStart()
   {
       #region SetupDiagnostics Set up diagnostics

       DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultIniialConfiguration();
       TimeSpan tsOneMinute = TimeSpan.FromMinutes(1);

       dmc.Logs.ScheduledTransferPeriod = tsOneMinute;     // Transfer logs every minute
       dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;    // Tansfer verbose, critical, etc. logs

       // Start up the diagnostic manager with the given configuration
       DiagnosticMonitor.Start("DiagnosticsConnectionString", dmc);

       #endregion
  }
Mike Kelly
  • 969
  • 1
  • 12
  • 23
  • Yes, I do that. It seems that my worker role was quietly crashing somewhere where I didn't have a try-catch block around code. – onnoweb Oct 18 '11 at 15:24