Provides the default output methods and behavior for tracing.
For a list of all members of this type, see DefaultTraceListener Members.
System.Object
System.MarshalByRefObject
System.Diagnostics.TraceListener
System.Diagnostics.DefaultTraceListener
[Visual Basic] <ComVisible(False)> Public Class DefaultTraceListener Inherits TraceListener [C#] [ComVisible(false)] public class DefaultTraceListener : TraceListener [C++] [ComVisible(false)] public __gc class DefaultTraceListener : public TraceListener [JScript] public ComVisible(false) class DefaultTraceListener extends TraceListener
This type is safe for multithreaded operations.
This class is automatically added to the Debug.Listeners and to the Trace.Listeners collections.
By default, Write and WriteLine methods emit the message to the OutputDebugString and to the Log method. For information about the OutputDebugString API, see the Platform SDK or MSDN.
The Fail method, by default, displays a message box when the application is running in a user interface mode; it also emits the message using 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" initializeData="c:\myListener.log" />
<remove type="System.Diagnostics.DefaultTraceListener"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Namespace: System.Diagnostics
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: System (in System.dll)
DefaultTraceListener Members | System.Diagnostics Namespace | TraceListener | TextWriterTraceListener | Debug | Trace