开发者

Only some trace messages getting logged

开发者 https://www.devze.com 2023-04-06 05:34 出处:网络
in my Azure app I have Trace.WriteLine() calls sprinkled about to track what the application is doing.

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 开发者_如何学Cideas?


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

精彩评论

暂无评论...
验证码 换一张
取 消