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

Attributes and Elements

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



Child Elements

Element Description
<add> Adds a listener to the Listeners collection.
<remove> Removes a listener from the Listeners collection.
<clear> Clears the Listeners collection for a trace source.

Parent Elements

Element Description
configuration The root element in every configuration file used by the common language runtime and .NET Framework applications.
system.diagnostics Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set.
sources Contains trace sources that initiate tracing messages.
source Specifies a trace source that initiates tracing messages.


Configuration File

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

See also