System.Diagnostics.TraceFilter Class

Provides the base class for trace filter implementations.

See Also: TraceFilter Members


public abstract class TraceFilter


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 TraceListener.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 System.Diagnostics.ConsoleTraceListener, but not to the event log by a System.Diagnostics.EventLogTraceListener.

Filters that inherit from the System.Diagnostics.TraceFilter class can be used by trace listeners that inherit from the System.Diagnostics.TraceListener class to perform filtering of events being traced. System.Diagnostics.TraceFilter contains a single method, TraceFilter.ShouldTrace(TraceEventCache, string, TraceEventType, int, string, Object[], object, Object[]), which takes event data and returns a flag indicating whether the event should be traced.


Namespace: System.Diagnostics
Assembly: System (in System.dll)
Assembly Versions:,