Runtime Tracing

Runtime tracing is the capability to perform debug tracing while a program is running. Sometimes it's necessary to have more control over what debugging information is displayed. Specific types of problems often indicate what information should be displayed in trace output. The TraceSwitch class is similar to the BooleanSwitch class in that it allows you to create a configuration file or set an environment variable. However, its real value comes in being able to specify a finer degree of granularity in determining what information is displayed. The example in Listing 31.8 demonstrates how to use the TraceSwitch class.

Listing 31.8. TraceSwitch Class Demo: TraceSwitchDemo.cs
 using System; using System.Diagnostics; /// <summary> ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.