WebProcessStatistics.FormatToString(WebEventFormatter) 方法

定義

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

C#
public virtual void FormatToString(System.Web.Management.WebEventFormatter formatter);

參數

formatter
WebEventFormatter

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

範例

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

C#
//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());
}

備註

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

適用於

產品 版本
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1