public class DefaultTraceListener : TraceListener
|
By default, DefaultTraceListener.Write and DefaultTraceListener.WriteLine methods emit the message to the OutputDebugString and to the Debugger.Log method. For information about the OutputDebugString API, see "OutputDebugString" in the Platform SDK or MSDN.
The DefaultTraceListener.Fail method, by default, displays a message box when the application is running in a user interface mode; it also emits the message using DefaultTraceListener.WriteLine.
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>
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. Initializes a new instance of the DefaultTraceListener class with "Default" as its TraceListener.Name. |
AssertUiEnabled | Read-write Gets or sets whether the application is running in user-interface mode. |
IndentLevel (inherited from System.Diagnostics.TraceListener) |
Read-write See base class member description: System.Diagnostics.TraceListener.IndentLevel Gets or sets the indent level. |
IndentSize (inherited from System.Diagnostics.TraceListener) |
Read-write See base class member description: System.Diagnostics.TraceListener.IndentSize Gets or sets the number of spaces in an indent. |
LogFileName | Read-write Gets or sets name of a log file to write trace or debug messages to. |
Name (inherited from System.Diagnostics.TraceListener) |
Read-write See base class member description: System.Diagnostics.TraceListener.Name Gets or sets a name for this TraceListener. |
Close (inherited from System.Diagnostics.TraceListener) |
See base class member description: System.Diagnostics.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 (inherited from System.Diagnostics.TraceListener) |
Overloaded:Dispose() See base class member description: System.Diagnostics.TraceListener.DisposeReleases 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) Overridden: Emits or displays a message and a stack trace for an assertion that always fails. |
Fail | Overloaded:Fail(string message, string detailMessage) Overridden: Emits or displays detailed messages and a stack trace for an assertion that always fails. |
Flush (inherited from System.Diagnostics.TraceListener) |
See base class member description: System.Diagnostics.TraceListener.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 (inherited from System.Diagnostics.TraceListener) |
Overloaded:Write(object o) See base class member description: System.Diagnostics.TraceListener.WriteWrites 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) Overridden: Writes the output to the OutputDebugString and the Debugger.Log method. |
Write (inherited from System.Diagnostics.TraceListener) |
Overloaded:Write(object o, string category) See base class member description: System.Diagnostics.TraceListener.WriteWrites 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 (inherited from System.Diagnostics.TraceListener) |
Overloaded:Write(string message, string category) See base class member description: System.Diagnostics.TraceListener.WriteWrites a category name and a message to the listener you create when you implement the TraceListener class. |
WriteLine (inherited from System.Diagnostics.TraceListener) |
Overloaded:WriteLine(object o) See base class member description: System.Diagnostics.TraceListener.WriteLineWrites 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) Overridden: Writes the output to the OutputDebugString and the Debugger.Log method followed by a carriage return and a line feed (\r\n). |
WriteLine (inherited from System.Diagnostics.TraceListener) |
Overloaded:WriteLine(object o, string category) See base class member description: System.Diagnostics.TraceListener.WriteLineWrites 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 (inherited from System.Diagnostics.TraceListener) |
Overloaded:WriteLine(string message, string category) See base class member description: System.Diagnostics.TraceListener.WriteLineWrites a category name and a message to the listener you create when you implement the TraceListener class, followed by a line terminator. |
NeedIndent (inherited from System.Diagnostics.TraceListener) |
Read-write See base class member description: System.Diagnostics.TraceListener.NeedIndent Gets or sets a value indicating whether to indent the output. |
Dispose (inherited from System.Diagnostics.TraceListener) |
Overloaded:Dispose(bool disposing) See base class member description: System.Diagnostics.TraceListener.DisposeReleases 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 (inherited from System.Diagnostics.TraceListener) |
See base class member description: System.Diagnostics.TraceListener.WriteIndent Writes the indent to the listener you create when you implement this class, and resets the TraceListener.NeedIndent property to false. |
Hierarchy:
public DefaultTraceListener(); |
public bool AssertUiEnabled {get; set;}
|
public int IndentLevel {get; set;}
|
public int IndentSize {get; set;}
|
public string LogFileName {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 override void Fail( |
message
message
detailMessage
~DefaultTraceListener(); |
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 override void Write( |
message
o
category
message
category
protected virtual void WriteIndent(); |
public virtual void WriteLine( |
o
public override void WriteLine( |
message
For information about the OutputDebugString API, see "OutputDebugString" in the Platform SDK or MSDN.
This method sets TraceListener.NeedIndent to true.
o
category
message
category