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

Provides a set of methods and properties that help you trace the execution of your code. This class cannot be inherited. More...

Static Public Member Functions

static void Flush ()
 Flushes the output buffer, and causes buffered data to be written to the P:System.Diagnostics.Trace.Listeners. More...
 
static void Close ()
 Flushes the output buffer, and then closes the P:System.Diagnostics.Trace.Listeners. More...
 
static void Assert (bool condition)
 Checks for a condition; if the condition is false, displays a message box that shows the call stack. More...
 
static void Assert (bool condition, string message)
 Checks for a condition; if the condition is false, outputs a specified message and displays a message box that shows the call stack. More...
 
static void Assert (bool condition, string message, string detailMessage)
 Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the call stack. More...
 
static void Fail (string message)
 Emits the specified error message. More...
 
static void Fail (string message, string detailMessage)
 Emits an error message, and a detailed error message. More...
 
static void Refresh ()
 Refreshes the trace configuration data. More...
 
static void TraceInformation (string message)
 Writes an informational message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified message. More...
 
static void TraceInformation (string format, params object[] args)
 Writes an informational message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified array of objects and formatting information. More...
 
static void TraceWarning (string message)
 Writes a warning message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified message. More...
 
static void TraceWarning (string format, params object[] args)
 Writes a warning message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified array of objects and formatting information. More...
 
static void TraceError (string message)
 Writes an error message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified message. More...
 
static void TraceError (string format, params object[] args)
 Writes an error message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified array of objects and formatting information. More...
 
static void Write (string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void Write (object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void Write (string message, string category)
 Writes a category name and a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void Write (object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void WriteLine (string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void WriteLine (object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void WriteLine (string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void WriteLine (object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection. More...
 
static void WriteIf (bool condition, string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteIf (bool condition, object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteIf (bool condition, string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteIf (bool condition, object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, string message)
 Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, object value)
 Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, string message, string category)
 Writes a category name and message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void WriteLineIf (bool condition, object value, string category)
 Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true. More...
 
static void Indent ()
 Increases the current P:System.Diagnostics.Trace.IndentLevel by one. More...
 
static void Unindent ()
 Decreases the current P:System.Diagnostics.Trace.IndentLevel by one. More...
 

Properties

static TraceListenerCollection Listeners [get]
 Gets the collection of listeners that is monitoring the trace output. More...
 
static bool AutoFlush [get, set]
 Gets or sets whether M:System.Diagnostics.Trace.Flush should be called on the P:System.Diagnostics.Trace.Listeners after every write. More...
 
static bool UseGlobalLock [get, set]
 Gets or sets a value indicating whether the global lock should be used. More...
 
static CorrelationManager CorrelationManager [get]
 Gets the correlation manager for the thread for this trace. More...
 
static int IndentLevel [get, set]
 Gets or sets the indent level. More...
 
static int IndentSize [get, set]
 Gets or sets the number of spaces in an indent. More...
 

Detailed Description

Provides a set of methods and properties that help you trace the execution of your code. This class cannot be inherited.

Definition at line 6 of file Trace.cs.

Member Function Documentation

◆ Assert() [1/3]

static void System.Diagnostics.Trace.Assert ( bool  condition)
static

Checks for a condition; if the condition is false, displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, a failure message is not sent and the message box is not displayed.

Definition at line 121 of file Trace.cs.

◆ Assert() [2/3]

static void System.Diagnostics.Trace.Assert ( bool  condition,
string  message 
)
static

Checks for a condition; if the condition is false, outputs a specified message and displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the specified message is not sent and the message box is not displayed.
messageThe message to send to the P:System.Diagnostics.Trace.Listeners collection.

Definition at line 130 of file Trace.cs.

◆ Assert() [3/3]

static void System.Diagnostics.Trace.Assert ( bool  condition,
string  message,
string  detailMessage 
)
static

Checks for a condition; if the condition is false, outputs two specified messages and displays a message box that shows the call stack.

Parameters
conditionThe conditional expression to evaluate. If the condition is true, the specified messages are not sent and the message box is not displayed.
messageThe message to send to the P:System.Diagnostics.Trace.Listeners collection.
detailMessageThe detailed message to send to the P:System.Diagnostics.Trace.Listeners collection.

Definition at line 140 of file Trace.cs.

◆ Close()

static void System.Diagnostics.Trace.Close ( )
static

Flushes the output buffer, and then closes the P:System.Diagnostics.Trace.Listeners.

Definition at line 112 of file Trace.cs.

◆ Fail() [1/2]

static void System.Diagnostics.Trace.Fail ( string  message)
static

Emits the specified error message.

Parameters
messageA message to emit.

Definition at line 148 of file Trace.cs.

◆ Fail() [2/2]

static void System.Diagnostics.Trace.Fail ( string  message,
string  detailMessage 
)
static

Emits an error message, and a detailed error message.

Parameters
messageA message to emit.
detailMessageA detailed message to emit.

Definition at line 157 of file Trace.cs.

◆ Flush()

static void System.Diagnostics.Trace.Flush ( )
static

Flushes the output buffer, and causes buffered data to be written to the P:System.Diagnostics.Trace.Listeners.

Definition at line 105 of file Trace.cs.

◆ Indent()

static void System.Diagnostics.Trace.Indent ( )
static

Increases the current P:System.Diagnostics.Trace.IndentLevel by one.

Definition at line 376 of file Trace.cs.

◆ Refresh()

static void System.Diagnostics.Trace.Refresh ( )
static

Refreshes the trace configuration data.

Definition at line 163 of file Trace.cs.

◆ TraceError() [1/2]

static void System.Diagnostics.Trace.TraceError ( string  message)
static

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

Parameters
messageThe informative message to write.

Definition at line 208 of file Trace.cs.

◆ TraceError() [2/2]

static void System.Diagnostics.Trace.TraceError ( string  format,
params object []  args 
)
static

Writes an error message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified array of objects and formatting information.

Parameters
formatA format string that contains zero or more format items, which correspond to objects in the args array.
argsAn object array containing zero or more objects to format.

Definition at line 217 of file Trace.cs.

◆ TraceInformation() [1/2]

static void System.Diagnostics.Trace.TraceInformation ( string  message)
static

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

Parameters
messageThe informative message to write.

Definition at line 174 of file Trace.cs.

◆ TraceInformation() [2/2]

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

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

Parameters
formatA format string that contains zero or more format items, which correspond to objects in the args array.
argsAn object array containing zero or more objects to format.

Definition at line 183 of file Trace.cs.

◆ TraceWarning() [1/2]

static void System.Diagnostics.Trace.TraceWarning ( string  message)
static

Writes a warning message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified message.

Parameters
messageThe informative message to write.

Definition at line 191 of file Trace.cs.

◆ TraceWarning() [2/2]

static void System.Diagnostics.Trace.TraceWarning ( string  format,
params object []  args 
)
static

Writes a warning message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection using the specified array of objects and formatting information.

Parameters
formatA format string that contains zero or more format items, which correspond to objects in the args array.
argsAn object array containing zero or more objects to format.

Definition at line 200 of file Trace.cs.

◆ Unindent()

static void System.Diagnostics.Trace.Unindent ( )
static

Decreases the current P:System.Diagnostics.Trace.IndentLevel by one.

Definition at line 383 of file Trace.cs.

◆ Write() [1/4]

static void System.Diagnostics.Trace.Write ( string  message)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
messageA message to write.

Definition at line 225 of file Trace.cs.

◆ Write() [2/4]

static void System.Diagnostics.Trace.Write ( object  value)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.

Definition at line 233 of file Trace.cs.

◆ Write() [3/4]

static void System.Diagnostics.Trace.Write ( string  message,
string  category 
)
static

Writes a category name and a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
messageA message to write.
categoryA category name used to organize the output.

Definition at line 242 of file Trace.cs.

◆ Write() [4/4]

static void System.Diagnostics.Trace.Write ( object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
valueAn T:System.Object name is sent to the P:System.Diagnostics.Trace.Listeners.
categoryA category name used to organize the output.

Definition at line 251 of file Trace.cs.

◆ WriteIf() [1/4]

static void System.Diagnostics.Trace.WriteIf ( bool  condition,
string  message 
)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.

Definition at line 295 of file Trace.cs.

◆ WriteIf() [2/4]

static void System.Diagnostics.Trace.WriteIf ( bool  condition,
object  value 
)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.

Definition at line 305 of file Trace.cs.

◆ WriteIf() [3/4]

static void System.Diagnostics.Trace.WriteIf ( bool  condition,
string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
categoryA category name used to organize the output.

Definition at line 316 of file Trace.cs.

◆ WriteIf() [4/4]

static void System.Diagnostics.Trace.WriteIf ( bool  condition,
object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.
categoryA category name used to organize the output.

Definition at line 327 of file Trace.cs.

◆ WriteLine() [1/4]

static void System.Diagnostics.Trace.WriteLine ( string  message)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
messageA message to write.

Definition at line 259 of file Trace.cs.

◆ WriteLine() [2/4]

static void System.Diagnostics.Trace.WriteLine ( object  value)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.

Definition at line 267 of file Trace.cs.

◆ WriteLine() [3/4]

static void System.Diagnostics.Trace.WriteLine ( string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
messageA message to write.
categoryA category name used to organize the output.

Definition at line 276 of file Trace.cs.

◆ WriteLine() [4/4]

static void System.Diagnostics.Trace.WriteLine ( object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection.

Parameters
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.
categoryA category name used to organize the output.

Definition at line 285 of file Trace.cs.

◆ WriteLineIf() [1/4]

static void System.Diagnostics.Trace.WriteLineIf ( bool  condition,
string  message 
)
static

Writes a message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.

Definition at line 337 of file Trace.cs.

◆ WriteLineIf() [2/4]

static void System.Diagnostics.Trace.WriteLineIf ( bool  condition,
object  value 
)
static

Writes the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.

Definition at line 347 of file Trace.cs.

◆ WriteLineIf() [3/4]

static void System.Diagnostics.Trace.WriteLineIf ( bool  condition,
string  message,
string  category 
)
static

Writes a category name and message to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
messageA message to write.
categoryA category name used to organize the output.

Definition at line 358 of file Trace.cs.

◆ WriteLineIf() [4/4]

static void System.Diagnostics.Trace.WriteLineIf ( bool  condition,
object  value,
string  category 
)
static

Writes a category name and the value of the object's M:System.Object.ToString method to the trace listeners in the P:System.Diagnostics.Trace.Listeners collection if a condition is true.

Parameters
conditiontrue to cause a message to be written; otherwise, false.
valueAn T:System.Object whose name is sent to the P:System.Diagnostics.Trace.Listeners.
categoryA category name used to organize the output.

Definition at line 369 of file Trace.cs.

Property Documentation

◆ AutoFlush

bool System.Diagnostics.Trace.AutoFlush
staticgetset

Gets or sets whether M:System.Diagnostics.Trace.Flush should be called on the P:System.Diagnostics.Trace.Listeners after every write.

Returns
true if M:System.Diagnostics.Trace.Flush is called on the P:System.Diagnostics.Trace.Listeners after every write; otherwise, false.

Definition at line 26 of file Trace.cs.

◆ CorrelationManager

CorrelationManager System.Diagnostics.Trace.CorrelationManager
staticget

Gets the correlation manager for the thread for this trace.

Returns
The T:System.Diagnostics.CorrelationManager object associated with the thread for this trace.

Definition at line 59 of file Trace.cs.

◆ IndentLevel

int System.Diagnostics.Trace.IndentLevel
staticgetset

Gets or sets the indent level.

Returns
The indent level. The default is zero.

Definition at line 74 of file Trace.cs.

◆ IndentSize

int System.Diagnostics.Trace.IndentSize
staticgetset

Gets or sets the number of spaces in an indent.

Returns
The number of spaces in an indent. The default is four.

Definition at line 88 of file Trace.cs.

◆ Listeners

TraceListenerCollection System.Diagnostics.Trace.Listeners
staticget

Gets the collection of listeners that is monitoring the trace output.

Returns
A T:System.Diagnostics.TraceListenerCollection that represents a collection of type T:System.Diagnostics.TraceListener monitoring the trace output.

Definition at line 13 of file Trace.cs.

◆ UseGlobalLock

bool System.Diagnostics.Trace.UseGlobalLock
staticgetset

Gets or sets a value indicating whether the global lock should be used.

Returns
true if the global lock is to be used; otherwise, false. The default is true.

Definition at line 43 of file Trace.cs.


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