Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (58 sloc) 2.98 KB
title ms.date f1_keywords helpviewer_keywords ms.assetid
<remove> Element for <listeners> for <trace>
03/30/2017
remove element
<remove> element
9a5cd1b5-be1a-485f-8f0c-2890ad3ef3e0

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

Removes a listener from the Listeners collection.

<configuration>
  <system.diagnostics>
    <trace>
      <listeners>
        <remove>

Syntax

<remove name="listener name" />  

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.
listeners Specifies a listener that collects, stores, and routes messages. Listeners direct the tracing output to an appropriate target.
system.diagnostics Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set.
trace Configures the ASP.NET trace service.

Remarks

[!NOTE] Removing the xref:System.Diagnostics.DefaultTraceListener from the Listeners collection alters the behavior of the xref:System.Diagnostics.Debug.Assert%2A?displayProperty=nameWithType, xref:System.Diagnostics.Trace.Assert%2A?displayProperty=nameWithType, xref:System.Diagnostics.Debug.Fail%2A?displayProperty=nameWithType, and xref:System.Diagnostics.Trace.Fail%2A?displayProperty=nameWithType methods. Calling an Assert or Fail method normally results in the display of a message box, however the message box is not displayed if the xref:System.Diagnostics.DefaultTraceListener is not in the Listeners collection.

Example

The following example shows how to remove the default trace listener from the trace Listeners collection.

<configuration>  
   <system.diagnostics>  
      <trace autoflush="true" indentsize="0">  
         <listeners>  
            <remove name="Default" />  
         </listeners>  
      </trace>  
   </system.diagnostics>  
</configuration>  

See also

  • xref:System.Diagnostics.TraceListener
  • xref:System.Diagnostics.DefaultTraceListener
  • xref:System.Diagnostics.TextWriterTraceListener
  • xref:System.Diagnostics.EventLogTraceListener
  • Trace and Debug Settings Schema
You can’t perform that action at this time.