The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

<listeners> Element for <source> 

Adds or removes listeners in the Listeners collection for a TraceSource. A listener directs the tracing output to an appropriate target, such as a log, window, or text file.

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

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

Removes a listener from the Listeners collection.

<clear> Element for <listeners> for <source>

Clears the Listeners collection for a trace source.

Parent Elements

Element Description


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


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


Contains trace sources that initiate tracing messages.


Specifies a trace source that initiates tracing messages.

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 a console trace listener to the mySource source and to remove the default trace listener.

      <source name="mySource" switchName="sourceSwitch" 
          <add name="console" 
            <filter type="System.Diagnostics.EventTypeFilter" 
          <remove name="Default"/>
      <add name="sourceSwitch" value="Warning"/>
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft