Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata