.NET Framework Class Library
TraceFilter Class

Provides the base class for trace filter implementations.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)
Syntax
Public MustInherit Class TraceFilter
public abstract class TraceFilter
public ref class TraceFilter abstract
[<[%$TOPIC/2z67k044_en-us_VS_110_2_0_3_0_0%]>]
type TraceFilter =  class end

The TraceFilter type exposes the following members.

Constructors
  NameDescription
Protected method TraceFilterInitializes a new instance of the TraceFilter class.
Top
Methods
  NameDescription
Public method Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method GetTypeGets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public method ShouldTraceWhen overridden in a derived class, determines whether the trace listener should trace the event.
Public method ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Remarks

Trace filters can be used by trace listeners to provide an extra layer of filtering beyond that provided by trace switches. The trace filter for a trace listener can be found in the listener's Filter property. Trace switches determine if a trace is to be sent to the trace listeners. Trace filters allow the individual trace listeners to determine whether or not the trace is to be written to the associated output medium. For example, as determined by each trace filter, a trace may be written to the console by a ConsoleTraceListener, but not to the event log by a EventLogTraceListener.

Filters that inherit from the TraceFilter class can be used by trace listeners that inherit from the TraceListener class to perform filtering of events being traced. TraceFilter contains a single method, ShouldTrace, which takes event data and returns a flag indicating whether the event should be traced.

Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.