<remove>的元素 <listeners><source><remove> Element for <listeners> for <source>

从跟踪源的 Listeners 集合中删除侦听器。Removes a listener from the Listeners collection for a trace source.



<remove name="listenerName" />  

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.


属性Attribute 描述Description
name 必需的特性。Required attribute.

要从集合中删除的侦听器的名称 ListenersThe name of the listener to remove from the Listeners collection.

子元素Child Elements


父元素Parent Elements

元素Element 描述Description
configuration 公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。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.


<remove>元素从跟踪源的集合中删除指定的侦听器 ListenersThe <remove> element removes a specified listener from the Listeners collection for a trace source.

您可以 Listeners 通过 Remove 对实例的属性调用方法,以编程方式从跟踪源的集合中移除一个元素 Listeners TraceSourceYou 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.

此元素可在计算机配置文件中使用 ( # A0) 和应用程序配置文件。This element can be used in the machine configuration file (Machine.config) and the application configuration file.


下面的示例演示如何 <remove> 在使用 <add> 元素将侦听器添加 consoleListeners 跟踪源的集合之前使用元素 TraceSourceAppThe 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.

      <source name="TraceSourceApp" switchName="sourceSwitch"
         switchType="System.Diagnostics.SourceSwitch" >  
           <remove name="Default"/>  
           <add name="console"
             type="System.Diagnostics.ConsoleTraceListener" />  

请参阅See also