public abstract class TraceListener : MarshalByRefObject, IDisposable
|
You must enable tracing or debugging to use a switch. The following syntax is compiler specific. If you use compilers other than C# or Visual Basic, refer to the documentation for your compiler.
To set the level of your listener, edit the configuration file that corresponds to the name of your application. Within this file, you can add a listener, set its type and set its parameter, remove a listener, or clear all the listeners previously set by the application. The configuration file should be formatted similar to the following example:
<configuration> <system.diagnostics> <switches> <add name="MagicTraceSwitch" value="3" /> </switches> <trace autoflush="false" indentsize="4"> <listeners> <add name="myListener" type="System.Diagnostics.TextWriterTraceListener,System" initializeData="c:\myListener.log" /> <remove type="System.Diagnostics.DefaultTraceListener,System"/> </listeners> </trace> </system.diagnostics> </configuration>
IndentLevel | Read-write Gets or sets the indent level. |
IndentSize | Read-write Gets or sets the number of spaces in an indent. |
Name | Read-write Gets or sets a name for this TraceListener. |
Close | When overridden in a derived class, closes the output stream so it no longer receives tracing or debugging output. |
CreateObjRef (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. |
Dispose | Overloaded:Dispose() Releases all resources used by the TraceListener. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
Fail | Overloaded:Fail(string message) Emits an error message to the listener you create when you implement the TraceListener class. |
Fail | Overloaded:Fail(string message, string detailMessage) Emits an error message, and a detailed error message to the listener you create when you implement the TraceListener class. |
Flush | When overridden in a derived class, flushes the output buffer. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
InitializeLifetimeService (inherited from System.MarshalByRefObject) |
See base class member description: System.MarshalByRefObject.InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Write | Overloaded:Write(object o) Writes the value of the object's Object.ToString method to the listener you create when you implement the TraceListener class. |
Write | Overloaded:Write(string message) When overridden in a derived class, writes the specified message to the listener you create in the derived class. |
Write | Overloaded:Write(object o, string category) Writes a category name and the value of the object's Object.ToString method to the listener you create when you implement the TraceListener class. |
Write | Overloaded:Write(string message, string category) Writes a category name and a message to the listener you create when you implement the TraceListener class. |
WriteLine | Overloaded:WriteLine(object o) Writes the value of the object's Object.ToString method to the listener you create when you implement the TraceListener class, followed by a line terminator. |
WriteLine | Overloaded:WriteLine(string message) When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator. |
WriteLine | Overloaded:WriteLine(object o, string category) Writes a category name and the value of the object's Object.ToString method to the listener you create when you implement the TraceListener class, followed by a line terminator. |
WriteLine | Overloaded:WriteLine(string message, string category) Writes a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator. |
ctor #1 | Overloaded:.ctor() Default constructor. This constructor is called by derived class constructors to initialize state in this type.Initializes a new instance of the TraceListener class. |
ctor #2 | Overloaded:.ctor(string name) Initializes a new instance of the TraceListener class using the specified name as the listener. |
NeedIndent | Read-write Gets or sets a value indicating whether to indent the output. |
Dispose | Overloaded:Dispose(bool disposing) Releases the unmanaged resources used by the TraceListener and optionally releases the managed resources. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
WriteIndent | Writes the indent to the listener you create when you implement this class, and resets the TraceListener.NeedIndent property to false. |
Hierarchy:
protected TraceListener(); |
Property | Default Value |
---|---|
Name | The empty string (""). |
Indent | Zero. |
IndentSize | Four spaces. |
protected TraceListener( |
name
public int IndentLevel {get; set;}
|
public int IndentSize {get; set;}
|
public virtual string Name {get; set;}
|
protected bool NeedIndent {get; set;}
|
public virtual void Close(); |
requestedType
Exception Type | Condition |
---|---|
RemotingException | This instance is not a valid remoting object. |
public void Dispose(); |
protected virtual void Dispose( |
disposing
When the disposing parameter is true, this method releases all resources held by any managed objects that this TraceListener references. This method invokes the Dispose() method of each referenced object.
For more information about Dispose and Finalize, see the conceptual topic at MSDN: cleaningupunmanagedresources and the conceptual topic at MSDN: overridingfinalizemethod.
public virtual void Fail( |
message
message
detailMessage
~TraceListener(); |
public virtual void Flush(); |
public virtual int GetHashCode(); |
public object GetLifetimeService(); |
public Type GetType(); |
public virtual object InitializeLifetimeService(); |
public class MyClass : MarshalByRefObject { public override Object InitializeLifetimeService() { ILease lease = (ILease)base.InitializeLifetimeService(); if (lease.CurrentState == LeaseState.Initial) { lease.InitialLeaseTime = TimeSpan.FromMinutes(1); lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); lease.RenewOnCallTime = TimeSpan.FromSeconds(2); } return lease; } }
protected object MemberwiseClone(); |
public virtual string ToString(); |
public virtual void Write( |
o
public abstract void Write( |
message
o
category
message
category
protected virtual void WriteIndent(); |
public virtual void WriteLine( |
o
public abstract void WriteLine( |
message
o
category
message
category