Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created September 23, 2012 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/3770583 to your computer and use it in GitHub Desktop.
Save codingoutloud/3770583 to your computer and use it in GitHub Desktop.
Turning on Windows Azure Diagnostics
// Simple approach, usually done in RoleEntryPoint::OnStart - though could be otherwise (even done remotely)
// See full working project at https://github.com/codingoutloud/SimpleWAD
public override bool OnStart()
{
Trace.Listeners.Add(new DiagnosticMonitorTraceListener());
Trace.AutoFlush = true;
Trace.TraceInformation("Error");
// Set up to transfer to blob storage
DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();
diagnosticConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(10);
// if not specified, will use overall quota (which is 4 GB):
// diagnosticConfiguration.Logs.BufferQuotaInMB = 10;
// Add the startup task logs directory, so the startup logs will get transferred to storage
var dirConfig = new DirectoryConfiguration();
dirConfig.Container = "wad-startuplogs-container";
dirConfig.Path = Path.Combine((new DirectoryInfo(".")).FullName, "startuplogs");
Trace.TraceInformation("=> dirConfig.Path = " + dirConfig.Path);
diagnosticConfiguration.Directories.DataSources.Add(dirConfig);
diagnosticConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(10);
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);
return base.OnStart();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment