Define trace class.
- The trace class in the code is used to diagnose the problem.
- You can use trace messages to your project to monitor events in the released version of the application.
- The trace class is found in the System.Diagnostics namespace.
- It provides a set of methods and properties that help you to trace the execution of your code.
- This class cannot be inherited.
Example:public sealed class Trace
Following are the properties of trace class:Properties | Description |
AutoFlush | Gets or sets whether Flush should be called on the Listeners after every write. |
CorrelationManager | Gets the correlation manager for the thread for this trace. |
IndentLevel | Gets or sets the indent level. |
IndentSize | Gets or sets the number of spaces in an indent. |
Listeners | Gets the collection of listeners that is monitoring the trace output. |
UseGlobalLock | Gets or sets a value indicating whether the global lock should be used. |
- You can use the properties and methods in the Trace class to instrument release builds.
- Tracing helps to isolate problems and fix them without disturbing a running system.
- It provides a method to display an Assert dialog box.
- It is used for testing and optimization even after an application is compiled and released.
- It uses the time of application deployment and runs in different thread form main program execute thread.