TraceSource TraceSource TraceSource TraceSource Constructors

Definition

Overloads

TraceSource(String) TraceSource(String) TraceSource(String) TraceSource(String)

Initializes a new instance of the TraceSource class, using the specified name for the source.

TraceSource(String, SourceLevels) TraceSource(String, SourceLevels) TraceSource(String, SourceLevels) TraceSource(String, SourceLevels)

Initializes a new instance of the TraceSource class, using the specified name for the source and the default source level at which tracing is to occur.

TraceSource(String) TraceSource(String) TraceSource(String) TraceSource(String)

Initializes a new instance of the TraceSource class, using the specified name for the source.

public:
 TraceSource(System::String ^ name);
public TraceSource (string name);
new System.Diagnostics.TraceSource : string -> System.Diagnostics.TraceSource
Public Sub New (name As String)

Parameters

name
String String String String

The name of the source (typically, the name of the application).

Exceptions

Examples

The following code example shows the use of the TraceSource constructor to create a new TraceSource object. This code example is part of a larger example provided for the TraceSource class.

// Initialize the trace source.
static TraceSource ts = new TraceSource("TraceTest");
' Initialize the trace source.
Private Shared ts As New TraceSource("TraceTest")

Remarks

The source name is used to identify traces. It is used by a SourceFilter to determine whether a trace listener should produce the trace. The recommended practice is to use the name of the application for the source name.

Note

It is not necessary to create a new TraceSource instance for each trace request. Create one TraceSource instance and use it for all trace requests for the application.

TraceSource(String, SourceLevels) TraceSource(String, SourceLevels) TraceSource(String, SourceLevels) TraceSource(String, SourceLevels)

Initializes a new instance of the TraceSource class, using the specified name for the source and the default source level at which tracing is to occur.

public:
 TraceSource(System::String ^ name, System::Diagnostics::SourceLevels defaultLevel);
public TraceSource (string name, System.Diagnostics.SourceLevels defaultLevel);
new System.Diagnostics.TraceSource : string * System.Diagnostics.SourceLevels -> System.Diagnostics.TraceSource
Public Sub New (name As String, defaultLevel As SourceLevels)

Parameters

name
String String String String

The name of the source, typically the name of the application.

defaultLevel
SourceLevels SourceLevels SourceLevels SourceLevels

A bitwise combination of the enumeration values that specifies the default source level at which to trace.

Exceptions

Remarks

The source name is used to identify traces. It can be used by a SourceSwitch to determine if tracing is to occur and by a SourceFilter to determine whether to produce the trace. The default source level is used by an EventTypeFilter to determine if tracing is to occur based on the source level of the message to be traced.

Note

It is not necessary to create a new TraceSource instance for each trace request. Create one TraceSource instance and use it for all trace requests for the application.

Applies to