Sdílet prostřednictvím


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

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

<configuration> Element
  <system.diagnostics> Element
    <sources> Element
      <source> Element
        <listeners> Element for <trace>
          <remove> Element for <listeners> for <source>

<remove name="listenerName" />

Attributes and Elements

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.

Remarks

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.

Example

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> 

See Also

Reference

Trace and Debug Settings Schema

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

Listeners

TraceSource

Concepts

Trace Listeners