Technology Backgrounder—Trace Switches and Trace Listeners

Trace Listeners

Trace listeners are thread-safe classes that derive from an abstract class called, appropriately enough, System.Diagnostics.TraceListener. This class contains the necessary methods to be able to control trace output. There are three out-of-the-box trace listeners included with .NET. The first is called DefaultTraceListener and, by default, is automatically added to a trace listener collection shared by the application. Using the Trace.Listeners static property, you can access this collection at any time during execution. Using the collection, you can then add or remove any trace listener. Controlling the listeners in the collection will, therefore, control your trace output. ...

Get .NET Patterns: Architecture, Design, and Process 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.