語言

TraceSource.Name 屬性

定義

取得追蹤源的名稱。

public:
 property System::String ^ Name { System::String ^ get(); };
public string Name { get; }
member this.Name : string
Public ReadOnly Property Name As String

屬性值

追蹤源的名稱。

範例

以下程式碼範例展示了如何在建構子呼叫中命名追蹤來源。 此程式碼範例是本類別更大範例 TraceSource 的一部分。

// Initialize the trace source.
static TraceSource ts = new TraceSource("TraceTest");
' Initialize the trace source.
Private Shared ts As New TraceSource("TraceTest")

備註

名稱由 name 傳給建構子的參數所設定。

你可以在 .NET Framework 應用程式的設定檔中使用 name 屬性來參考追蹤來源。 以下 XML 元素說明如何在 .NET Framework 應用程式的設定檔中引用追蹤來源。

<configuration>
  <system.diagnostics>
    <sources>
      <source name="TraceTest">
      </source>
    </sources>
  </system.diagnostics>
</configuration>

適用於