Share via


WebThreadInformation.FormatToString(WebEventFormatter) 方法

定義

格式化執行緒相關的資訊。

public:
 void FormatToString(System::Web::Management::WebEventFormatter ^ formatter);
public void FormatToString (System.Web.Management.WebEventFormatter formatter);
member this.FormatToString : System.Web.Management.WebEventFormatter -> unit
Public Sub FormatToString (formatter As WebEventFormatter)

參數

formatter
WebEventFormatter

包含用來將 Web 健康情況事件資訊格式化之定位和縮排設定的 WebEventFormatter

範例

下列程式碼範例示範如何格式化自訂資訊。


// Formats Web request event information.
public override void FormatCustomEventDetails(
 WebEventFormatter formatter)
{

    // Add custom data.

    formatter.AppendLine("");
    formatter.AppendLine(
        "Custom Thread Information:");

    formatter.IndentationLevel += 1;

    // Display the thread information obtained 
    formatter.AppendLine(GetThreadImpersonation());
    formatter.AppendLine(GetThreadStackTrace());
    formatter.AppendLine(GetThreadAccountName());
    formatter.AppendLine(GetThreadId());
    formatter.IndentationLevel -= 1;

    formatter.AppendLine(eventInfo.ToString());
}
' Formats Web request event information.
 Public Overrides Sub FormatCustomEventDetails( _
 ByVal formatter As WebEventFormatter)

     ' Add custom data.
     formatter.AppendLine("")
     formatter.AppendLine( _
     "Custom Thread Information:")

     formatter.IndentationLevel += 1

     ' Display the thread information obtained 
     formatter.AppendLine(GetThreadImpersonation())
     formatter.AppendLine(GetThreadStackTrace())
     formatter.AppendLine(GetThreadAccountName())
     formatter.AppendLine(GetThreadId())
     formatter.IndentationLevel -= 1

     formatter.AppendLine(eventInfo.ToString())
 End Sub

備註

方法 FormatToString 提供事件資訊的統一格式,如果必須記錄事件資料,且稍後會向使用者呈現,這非常有用。 當提供者叫用其中 ToString 一個方法時,會在內部呼叫它。

適用於