Created
September 23, 2012 12:48
-
-
Save codingoutloud/3770583 to your computer and use it in GitHub Desktop.
Turning on Windows Azure Diagnostics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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