O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

TraceListener

Synopsis

This abstract class TraceListener is associated with a trace through inclusion in the Trace.Listeners collection. Each TraceListener is responsible for sending trace output somewhere. For example, when you call Trace.WriteLine(), each TraceListener sends the same output to its respective output destination. Use Name to give a name to your TraceListener instances.

Use IndentLevel to control the level of indentation in the output. IndentSize specifies the number of spaces in each level of indent. NeedIndent toggles whether to indent the output at all. Use Write() and WriteLine() to send output to the TraceListener’s destination. WriteIndent() emits whitespace according to the current IndentLevel and IndentSize. It has the side effect of setting NeedIndent to false, so the next time you call one of the Write* methods, it will not emit extra indentation.

You can use the application configuration file to add or remove TraceListeners. Look up System.Diagnostics.TraceListener in the .NET Framework SDK Documentation for details.

public abstract class TraceListener : MarshalByRefObject : IDisposable {
// Protected Constructors
   protected method TraceListener();  
   protected method TraceListener(string name);  
// Public Instance Properties
   public field int IndentLevel{set; get; } 
   public field int IndentSize{set; get; } 
   public virtual field string Name{set; get; } 
// Protected Instance Properties
   protected field bool NeedIndent{set; get; } 
// Public Instance Methods ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required