<filter> Element for <add> for <sharedListeners>

Adds a filter to a listener in the sharedListeners collection.

<filter type="System.Diagnostics.EventTypeFilter" 
  initializeData="Warning" />

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


Attribute Description


Required attribute.

Specifies the type of the filter. You can use only the full name of the type (in the format of the System.Type.FullName property), or you can use the fully qualified type name including the assembly information (in the format of the System.Type.AssemblyQualifiedName property). For information on creating a fully qualified type name, see Specifying Fully Qualified Type Names.


Optional attribute.

The string passed to the constructor for the specified class.

Child Elements


Parent Elements

Element Description


The root element in every configuration file used by the common language runtime and .NET Framework applications.


Specifies trace listeners that collect, store, and route messages and the level where a trace switch is set.


A collection of listeners that any source or trace element can reference.


Adds a listener to the sharedListeners collection.

If a listener is defined in an <add> element of the <sharedListeners> element, the filter for that listener should be defined in a <filter> element that is a child of the <add> element.

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 <filter> element to add a filter to the trace listener console in the sharedListeners collection.

      <source name="myTraceSource" >
          <add name="console" />
          <remove name="Default" />
      <add name="console" 
        type="System.Diagnostics.ConsoleTraceListener" >
        <filter type="System.Diagnostics.EventTypeFilter" 
          initializeData="Error" />

Community Additions