共用方式為


WebProcessInformation.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)
{
    base.FormatCustomEventDetails(formatter);

    // Add custom data.
    formatter.AppendLine("Custom Process Information:");
    formatter.IndentationLevel += 1;

    // Display the process information.
    formatter.AppendLine(GetAccountName());
    formatter.AppendLine(GetProcessId());
    formatter.AppendLine(GetProcessName());
    formatter.IndentationLevel -= 1;
    formatter.AppendLine(eventInfo.ToString());
}
 'Formats Web request event information.
 Public Overrides Sub FormatCustomEventDetails( _
 ByVal formatter _
 As System.Web.Management.WebEventFormatter)
     MyBase.FormatCustomEventDetails(formatter)

     ' Add custom data.
     formatter.AppendLine("")
     formatter.AppendLine( _
     "Custom Process Information:")
     formatter.IndentationLevel += 1

     ' Display the process information.
     formatter.AppendLine(GetAccountName())
     formatter.AppendLine(GetProcessId())
     formatter.AppendLine(GetProcessName())
     formatter.IndentationLevel -= 1
     formatter.AppendLine(eventInfo.ToString())
 End Sub

備註

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

適用於