Share via


WebProcessStatistics.FormatToString(WebEventFormatter) 方法

定義

將處理序統計資料安排成適當格式。

public:
 virtual void FormatToString(System::Web::Management::WebEventFormatter ^ formatter);
public virtual void FormatToString (System.Web.Management.WebEventFormatter formatter);
abstract member FormatToString : System.Web.Management.WebEventFormatter -> unit
override this.FormatToString : System.Web.Management.WebEventFormatter -> unit
Public Overridable 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("");
    formatter.AppendLine(
        "Custom Process Statistics:");

    formatter.IndentationLevel += 1;

    // Get the process statistics.
    formatter.AppendLine(GetAppDomainCount());
    formatter.AppendLine(GetManagedHeapSize());
    formatter.AppendLine(GetPeakWorkingSet());
    formatter.AppendLine(GetProcessStartTime());
    formatter.AppendLine(GetRequestsExecuting());
    formatter.AppendLine(GetRequestsQueued());
    formatter.AppendLine(GetRequestsRejected());
    formatter.AppendLine(GetThreadCount());
    formatter.AppendLine(GetWorkingSet());

    formatter.IndentationLevel -= 1;

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

        ' Add custom data.
        formatter.AppendLine("")
        formatter.AppendLine("Custom Process Statistics:")

        formatter.IndentationLevel += 1

        ' Get the process statistics.
        formatter.AppendLine(GetAppDomainCount())
        formatter.AppendLine(GetManagedHeapSize())
        formatter.AppendLine(GetPeakWorkingSet())
        formatter.AppendLine(GetProcessStartTime())
        formatter.AppendLine(GetRequestsExecuting())
        formatter.AppendLine(GetRequestsQueued())
        formatter.AppendLine(GetRequestsRejected())
        formatter.AppendLine(GetThreadCount())
        formatter.AppendLine(GetWorkingSet())

        formatter.IndentationLevel -= 1

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

備註

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

適用於