다음을 통해 공유


SourceFilter(String) 생성자

정의

추적 원본의 이름을 지정하여 클래스의 SourceFilter 새 인스턴스를 초기화합니다.

public:
 SourceFilter(System::String ^ source);
public SourceFilter(string source);
new System.Diagnostics.SourceFilter : string -> System.Diagnostics.SourceFilter
Public Sub New (source As String)

매개 변수

source
String

추적 원본의 이름입니다.

예제

다음 코드 예제에서는 두 개의 서로 다른 소스 필터를 사용 하 여 메서드를 호출 TraceData 합니다. 하나는 가상의 이름을 사용 하 여 다른 현재 추적 소스의 이름을 사용 하 여 합니다. 첫 번째 경우 추적은 콘솔에 기록되지 않습니다. 두 번째 경우에서 추적이 기록됩니다. 이 코드 예제는 클래스에 제공된 더 큰 예제의 TraceSource 일부입니다.

// Test the filter on the ConsoleTraceListener.
ts.Listeners["console"].Filter = new SourceFilter("No match");
ts.TraceData(TraceEventType.Information, 5,
    "SourceFilter should reject this message for the console trace listener.");
ts.Listeners["console"].Filter = new SourceFilter("TraceTest");
ts.TraceData(TraceEventType.Information, 6,
    "SourceFilter should let this message through on the console trace listener.");
' Test the filter on the ConsoleTraceListener.
ts.Listeners("console").Filter = New SourceFilter("No match")
ts.TraceData(TraceEventType.Information, 5, "SourceFilter should reject this message for the console trace listener.")
ts.Listeners("console").Filter = New SourceFilter("TraceTest")
ts.TraceData(TraceEventType.Information, 6, "SourceFilter should let this message through on the console trace listener.")

설명

매개 변수의 source 값은 속성을 초기화하는 Source 데 사용됩니다.

적용 대상