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

<remove> Element for <listeners> for <source> 

Removes a listener from the Listeners collection for a trace source.


<remove name="listenerName" />

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

Attributes

Attribute Description

name

Required attribute.

The name of the listener to remove from the Listeners collection.

Child Elements

None.

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.

listeners

Specifies listeners that collect, store, and route messages.

The <remove> element removes a specified listener from the Listeners collection for a trace source.

You can remove an element from the Listeners collection for a trace source programmatically by calling the Remove method on the Listeners property of the TraceSource instance.

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 <remove> element before using the <add> element to add the listener console to the Listeners collection for the trace source TraceSourceApp.

<configuration>
  <system.diagnostics>
    <sources>
      <source name="TraceSourceApp" switchName="sourceSwitch" 
         switchType="System.Diagnostics.SourceSwitch" >
         <listeners>
           <remove name="Default"/>
           <add name="console" 
             type="System.Diagnostics.ConsoleTraceListener" />
         </listeners>
      </source>
    </sources>
  </system.diagnostics>
</configuration> 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft