<system.diagnostics> Element
Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set.
<system.diagnostics> </system.diagnostics>
The following sections describe attributes, child elements, and parent elements.
Attributes
None.
Child Elements
| Element | Description |
|---|---|
| Specifies whether to display a message box when you call the Debug.Assert method; also specifies the name of the file to write messages to. | |
| Specifies the size of the global memory shared by performance counters. | |
| Contains listeners that any source or trace element can reference. Listeners identified as shared listeners can be added to sources or traces by name. | |
| Specifies trace sources that initiate tracing messages. | |
| Contains trace switches and the levels where the trace switches are set. | |
| Contains listeners that collect, store, and route tracing messages. |
Parent Elements
| Element | Description |
|---|---|
| configuration | The root element in every configuration file used by the common language runtime and .NET Framework applications. |
The following example shows how to embed a trace switch and a trace listener inside the <system.diagnostics> element. The General trace switch is set to the TraceLevel.Error level. The trace listener myListener creates a file called MyListener.log and writes the output to the file.
Note |
|---|
| In the .NET Framework version 2.0, you can use text to specify the value for a switch. For example, you can specify true for a BooleanSwitch or use the text representing an enumeration value such as Error for a TraceSwitch. The line <add name="myTraceSwitch" value="Error" /> is equivalent to <add name="myTraceSwitch" value="1" />. |
<configuration>
<system.diagnostics>
<switches>
<add name="General" value="4" />
</switches>
<trace autoflush="true" indentsize="2">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" initializeData="MyListener.log" traceOutputOptions="ProcessId, LogicalOperationStack, Timestamp, ThreadId, Callstack, DateTime" />
</listeners>
</trace>
</system.diagnostics>
</configuration>
Note