Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set.
<configuration>
<system.diagnostics>
<system.diagnostics>
</system.diagnostics>
Child Elements
Element | Description |
---|---|
<assert> | 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. |
<switches> | Contains trace switches and the levels where the trace switches are set. |
<trace> | Contains listeners that collect, store, and route tracing messages. |
Example
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.
<configuration>
<system.diagnostics>
<switches>
<add name="General" value="4" />
</switches>
<trace autoflush="true" indentsize="2">
<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener, Version, Culture, PublicKeyToken"
initializeData="MyListener.log"/>
</listeners>
</trace>
</system.diagnostics>
</configuration>
Configuration File
This element can be used in the machine configuration file (Machine.config) and the application configuration file.