This documentation is archived and is not being maintained.

<trace> Element

Contains listeners that collect, store, and route tracing messages.


<trace autoflush="true|false" 
       indentsize="indent value"/>

Optional Attributes

Attribute Description
autoflush Specifies whether the trace listeners automatically flush the output buffer after every write operation. Specify one of the following values:
Automatically flushes the output buffer.
Does not automatically flush the output buffer. This is the default.
indentsize Specifies the number of spaces to indent.

Child Elements

Element Description
<listeners> Specifies a listener that collects, stores, and routes messages.


The following example shows how to use the <trace> element to add the listener MyListener to the Listeners collection. MyListener creates a file called MyListener.log and writes the output to the file. The autoflush attribute is set to true, which causes the trace listener to write to the file regardless of whether the Trace.Flush method is called. The indentsize attribute is set to 0, which causes the listener to indent zero spaces when the Trace.Indent method is called.

      <trace autoflush="true" indentsize="0">
            <add name="MyListener"
                 type="System.Diagnostics.TextWriterTraceListener, Version, Culture, PublicKeyToken" 

Configuration File

This element can be used in the machine configuration file (Machine.config) and the application configuration file.

See Also

Trace and Debug Settings Schema | TraceListener Class | DefaultTraceListener Class | TextWriterTraceListener Class | EventLogTraceListener Class