mscorlib(4.0.0.0) API with additions
System.Diagnostics.TraceSource Class Reference

Provides a set of methods and properties that enable applications to trace the execution of code and associate trace messages with their source. More...

Public Member Functions

 TraceSource (string name)
 Initializes a new instance of the T:System.Diagnostics.TraceSource class, using the specified name for the source. More...
 
 TraceSource (string name, SourceLevels defaultLevel)
 Initializes a new instance of the T:System.Diagnostics.TraceSource class, using the specified name for the source and the default source level at which tracing is to occur. More...
 
void Close ()
 Closes all the trace listeners in the trace listener collection. More...
 
void Flush ()
 Flushes all the trace listeners in the trace listener collection. More...
 
void TraceEvent (TraceEventType eventType, int id)
 Writes a trace event message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type and event identifier. More...
 
void TraceEvent (TraceEventType eventType, int id, string message)
 Writes a trace event message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and message. More...
 
void TraceEvent (TraceEventType eventType, int id, string format, params object[] args)
 Writes a trace event to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and argument array and format. More...
 
void TraceData (TraceEventType eventType, int id, object data)
 Writes trace data to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and trace data. More...
 
void TraceData (TraceEventType eventType, int id, params object[] data)
 Writes trace data to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and trace data array. More...
 
void TraceInformation (string message)
 Writes an informational message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified message. More...
 
void TraceInformation (string format, params object[] args)
 Writes an informational message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified object array and formatting information. More...
 
void TraceTransfer (int id, string message, Guid relatedActivityId)
 Writes a trace transfer message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified numeric identifier, message, and related activity identifier. More...
 

Public Attributes

string Name => sourceName
 Gets the name of the trace source. More...
 

Protected Member Functions

virtual internal string [] GetSupportedAttributes ()
 Gets the custom attributes supported by the trace source. More...
 

Properties

StringDictionary Attributes [get]
 Gets the custom switch attributes defined in the application configuration file. More...
 
TraceListenerCollection Listeners [get]
 Gets the collection of trace listeners for the trace source. More...
 
SourceSwitch Switch [get, set]
 Gets or sets the source switch value. More...
 

Detailed Description

Provides a set of methods and properties that enable applications to trace the execution of code and associate trace messages with their source.

Definition at line 9 of file TraceSource.cs.

Constructor & Destructor Documentation

◆ TraceSource() [1/2]

System.Diagnostics.TraceSource.TraceSource ( string  name)

Initializes a new instance of the T:System.Diagnostics.TraceSource class, using the specified name for the source.

Parameters
nameThe name of the source (typically, the name of the application).
Exceptions
T:System.ArgumentNullExceptionname is null.
T:System.ArgumentExceptionname is an empty string ("").

Definition at line 87 of file TraceSource.cs.

◆ TraceSource() [2/2]

System.Diagnostics.TraceSource.TraceSource ( string  name,
SourceLevels  defaultLevel 
)

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

Parameters
nameThe name of the source, typically the name of the application.
defaultLevelA bitwise combination of the enumeration values that specifies the default source level at which to trace.
Exceptions
T:System.ArgumentNullExceptionname is null.
T:System.ArgumentExceptionname is an empty string ("").

Definition at line 99 of file TraceSource.cs.

Member Function Documentation

◆ Close()

void System.Diagnostics.TraceSource.Close ( )

Closes all the trace listeners in the trace listener collection.

Definition at line 200 of file TraceSource.cs.

◆ Flush()

void System.Diagnostics.TraceSource.Flush ( )

Flushes all the trace listeners in the trace listener collection.

Exceptions
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 216 of file TraceSource.cs.

◆ GetSupportedAttributes()

virtual internal string [] System.Diagnostics.TraceSource.GetSupportedAttributes ( )
protectedvirtual

Gets the custom attributes supported by the trace source.

Returns
A string array naming the custom attributes supported by the trace source, or null if there are no custom attributes.

Definition at line 252 of file TraceSource.cs.

◆ TraceData() [1/2]

void System.Diagnostics.TraceSource.TraceData ( TraceEventType  eventType,
int  id,
object  data 
)

Writes trace data to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and trace data.

Parameters
eventTypeOne of the enumeration values that specifies the event type of the trace data.
idA numeric identifier for the event.
dataThe trace data.
Exceptions
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 513 of file TraceSource.cs.

◆ TraceData() [2/2]

void System.Diagnostics.TraceSource.TraceData ( TraceEventType  eventType,
int  id,
params object []  data 
)

Writes trace data to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and trace data array.

Parameters
eventTypeOne of the enumeration values that specifies the event type of the trace data.
idA numeric identifier for the event.
dataAn object array containing the trace data.
Exceptions
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 566 of file TraceSource.cs.

◆ TraceEvent() [1/3]

void System.Diagnostics.TraceSource.TraceEvent ( TraceEventType  eventType,
int  id 
)

Writes a trace event message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type and event identifier.

Parameters
eventTypeOne of the enumeration values that specifies the event type of the trace data.
idA numeric identifier for the event.
Exceptions
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 349 of file TraceSource.cs.

◆ TraceEvent() [2/3]

void System.Diagnostics.TraceSource.TraceEvent ( TraceEventType  eventType,
int  id,
string  message 
)

Writes a trace event message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and message.

Parameters
eventTypeOne of the enumeration values that specifies the event type of the trace data.
idA numeric identifier for the event.
messageThe trace message to write.
Exceptions
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 402 of file TraceSource.cs.

◆ TraceEvent() [3/3]

void System.Diagnostics.TraceSource.TraceEvent ( TraceEventType  eventType,
int  id,
string  format,
params object []  args 
)

Writes a trace event to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified event type, event identifier, and argument array and format.

Parameters
eventTypeOne of the enumeration values that specifies the event type of the trace data.
idA numeric identifier for the event.
formatA composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the args array.
argsAn object array containing zero or more objects to format.
Exceptions
T:System.ArgumentNullExceptionformat is null.
T:System.FormatExceptionformat is invalid.-or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format.
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 460 of file TraceSource.cs.

◆ TraceInformation() [1/2]

void System.Diagnostics.TraceSource.TraceInformation ( string  message)

Writes an informational message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified message.

Parameters
messageThe informative message to write.
Exceptions
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 617 of file TraceSource.cs.

◆ TraceInformation() [2/2]

void System.Diagnostics.TraceSource.TraceInformation ( string  format,
params object []  args 
)

Writes an informational message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified object array and formatting information.

Parameters
formatA composite format string (see Remarks) that contains text intermixed with zero or more format items, which correspond to objects in the args array.
argsAn array containing zero or more objects to format.
Exceptions
T:System.ArgumentNullExceptionformat is null.
T:System.FormatExceptionformat is invalid.-or- The number that indicates an argument to format is less than zero, or greater than or equal to the number of specified objects to format.
T:System.ObjectDisposedExceptionAn attempt was made to trace an event during finalization.

Definition at line 631 of file TraceSource.cs.

◆ TraceTransfer()

void System.Diagnostics.TraceSource.TraceTransfer ( int  id,
string  message,
Guid  relatedActivityId 
)

Writes a trace transfer message to the trace listeners in the P:System.Diagnostics.TraceSource.Listeners collection using the specified numeric identifier, message, and related activity identifier.

Parameters
idA numeric identifier for the event.
messageThe trace message to write.
relatedActivityIdA structure that identifies the related activity.

Definition at line 641 of file TraceSource.cs.

Member Data Documentation

◆ Name

string System.Diagnostics.TraceSource.Name => sourceName

Gets the name of the trace source.

Returns
The name of the trace source.

Definition at line 44 of file TraceSource.cs.

Property Documentation

◆ Attributes

StringDictionary System.Diagnostics.TraceSource.Attributes
get

Gets the custom switch attributes defined in the application configuration file.

Returns
A T:System.Collections.Specialized.StringDictionary containing the custom attributes for the trace switch.

Definition at line 30 of file TraceSource.cs.

◆ Listeners

TraceListenerCollection System.Diagnostics.TraceSource.Listeners
get

Gets the collection of trace listeners for the trace source.

Returns
A T:System.Diagnostics.TraceListenerCollection that contains the active trace listeners associated with the source.

Definition at line 49 of file TraceSource.cs.

◆ Switch

SourceSwitch System.Diagnostics.TraceSource.Switch
getset

Gets or sets the source switch value.

Returns
A T:System.Diagnostics.SourceSwitch object representing the source switch value.
Exceptions
T:System.ArgumentNullExceptionP:System.Diagnostics.TraceSource.Switch is set to null.

Definition at line 63 of file TraceSource.cs.


The documentation for this class was generated from the following file: