This documentation is archived and is not being maintained.

<listeners> Element for <trace> 

Specifies a listener that collects, stores, and routes messages. Listeners direct the tracing output to an appropriate target.

  <remove ... />

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



Child Elements

Element Description

<add> Element for <listeners> for <trace>

Adds a listener to the Listeners collection.

<clear> Element for <listeners> for <trace>

Clears the Listeners collection for trace.

<remove> Element for <listeners> for <trace>

Removes a listener from the Listeners collection.

Parent Elements

Element Description


The root element in every configuration file used by the common language runtime and .NET Framework applications.


Specifies the root element for the ASP.NET configuration section.


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

The Debug and Trace classes share the same Listeners collection. If you add a listener object to the collection in one of these classes, the other class uses the same listener. The listener classes shipped with the .NET Framework derive from the TraceListener class.

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

The following example shows how to use the <listeners> element to add the listeners MyListener and MyEventListener to the Listeners collection. MyListener creates a file called MyListener.log and writes the output to the file. MyEventListener creates an entry in the event log.

    <trace autoflush="true" indentsize="0">
        <add name="myListener" 
            system version=1.0.3300.0, Culture=neutral, 
          initializeData="c:\myListener.log" />
        <add name="MyEventListener"
            system version=1.0.3300.0, Culture=neutral,