« Upgrade Domains and Fault Domains in Windows Azure | Main | Collecting Event Logs in Windows Azure »

April 27, 2010

Windows Azure Diagnostics–Where Are My Logs?

Recently I noticed that lot of developers who are just starting to use Windows Azure hit issues with diagnostics and logging. It seems I didn’t go the same path other people go, because I was able to get diagnostics running from the first time. Therefore I decided to investigate what could possibly be the problem.

I created quite simple Web application with only one Web Role and one instance of it. The only purpose of the application was to write trace message every time a button is clicked on a web page.

In the onStart() method of the Web role I commented out the following line:




and added my custom log configuration:

DiagnosticMonitorConfiguration dmc =
dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

DiagnosticMonitor.Start("DiagnosticsConnectionString", dmc);

Here is also the event handler for the button:

protected void BtnSmile_Click(object sender, EventArgs e)
    if (this.lblSmile == null || this.lblSmile.Text == "")
    this.lblSmile.Text = ":)";
    this.lblSmile.Text = "";
    System.Diagnostics.Trace.WriteLine("Not smiling...");

This code worked perfectly, and I was able to get my trace messages after about a minute running the app in DevFabric.

After confirming that the diagnostics infrastructure works as expected my next goal was to see under what conditions I will see no logs generated by Windows Azure Diagnostics infrastructure. I reverted all the changes in the onStart() method and ran the application again. Not very surprisingly I saw no logs after minute wait time. Somewhere in my mind popped the value 5 mins, and I decided to wait. But even after 5 or 10, or 15 mins I saw nothing in the WADLogsTable. Apparently the problem comes from the default configuration of the DiagnosticMonitor, done through the following line:




Looking at the code I discovered that the default configuration uses


ScheduledTransferPeriodInMinutes = 0


Unfortunately this doesn’t work well with Windows Azure Diagnostics infrastructure, and is the main cause for the missing logs.

I simulated that quite easily with changing the following line in my custom configuration:


dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);




dmc.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(0);


Windows Azure Diagnostics does not accept values below 1 min for transfer period. Thus you should always get diagnostics configured according to your needs, and if you don’t want to use scheduled transfers you should make sure you push out the logs in your code.

I will continue my investigation of logging in one of my subsequent posts but for now I think this will be quite helpful for people.

Update: I circled back with our developers and they reminded me that not transfering the logs by default was intentional. The reason being that you will incurr charges for the logs stored in your storage account.




Feed You can follow this conversation by subscribing to the comment feed for this post.

Mike Kelly

Good post - you're right that information is still coming on Azure Diagnostics. I wrote an article on the topic for MSDN that will run in the June issue. There is a tool, Azure Diagnostics Monitor, which Cerebrata (www.cerebrata.com) makes that can be useful. There also is a sample that uses WCF to grab a live trace of the Azure service. Finally, you can use the Azure cmdlets (from code.msdn.microsoft.com/azurecmdlets) to adjust your diagnostics parameters and even do a demand transfer of logs right now.


Hi Mike,

Thanks for your comment. I use Azure Diagnostics Manager and find it quite handy to look at the logs. In the future I may post something about the cmdlets and the WCF sample as those are quite useful too but I think there are more advanced topics, and people are strungling with some basics still.

Post a comment

Comments are moderated, and will not appear on this weblog until the author has approved them.

If you have a TypeKey or TypePad account, please Sign In