<system.diagnostics> Element

Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set.




Attributes and Elements

The following sections describe attributes, child elements, and parent elements.



Child Elements

Element Description
<assert> Specifies whether to display a message box when you call the System.Diagnostics.Debug.Assert method; also specifies the name of the file to write messages to.
<performanceCounters> Specifies the size of the global memory shared by performance counters.
<sharedListeners> Contains listeners that any source or trace element can reference. Listeners identified as shared listeners can be added to sources or traces by name.
<sources> Specifies trace sources that initiate tracing messages.
<switches> Contains trace switches and the levels where the trace switches are set.
<trace> 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 level. The trace listener myListener creates a file called MyListener.log and writes the output to the file.


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" />.

         <add name="General" value="4" />  
      <trace autoflush="true" indentsize="2">  
            <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" />  

See Also

Trace and Debug Settings Schema