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

Adds a filter to a listener in the sharedListeners collection.



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

Attributes and Elements

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


Attribute Description
type Required attribute.

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

The string passed to the constructor for the specified class.

Child Elements


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.
sharedListeners A collection of listeners that any source or trace element can reference.
add 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" />  

See also