Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
codingoutloud / TraceToComputeEmulator.cs
Last active November 17, 2016 09:41
Enable Diagnostic Trace Logging for Windows Azure Compute Emulator from ASP.NET
// Code snippet for use in Windows Azure Cloud Services.
// The EnableDiagnosticTraceLoggingForComputeEmulator method can be called from ASP.NET
// code to enable output from the System.Diagnostics.Trace class to appear in the
// Windows Azure Compute Emulator. The method does nothing when deployed to the cloud,
// when run outside the compute emulator, when run other than in DEBUG, or run repeatedly.
//
// The code uses Reflection to dynamically load the needed assembly and create the
// specific TraceListener class needed.
//
// EXAMPLE INITIALIZING FROM Global.asax.