WebApplicationInformation.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

Объект WebEventFormatter, содержащий сведения о табуляции и отступах, используемые для форматирования сведений о веб-событиях работоспособности.

Примеры

В следующем примере кода показано, как форматировать пользовательские сведения.

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

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

    // Display the application information.
    formatter.AppendLine(GetApplicationDomain());
    formatter.AppendLine(GetApplicationPath());
    formatter.AppendLine(GetApplicationVirtualPath());
    formatter.AppendLine(GetApplicationMachineName());
    formatter.AppendLine(GetApplicationTrustLevel());
    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( _
        "Custom Application Information:")
        formatter.IndentationLevel += 1

        ' Display the application information.
        formatter.AppendLine(GetApplicationDomain())
        formatter.AppendLine(GetApplicationPath())
        formatter.AppendLine(GetApplicationVirtualPath())
        formatter.AppendLine(GetApplicationMachineName())
        formatter.AppendLine(GetApplicationTrustLevel())
        formatter.IndentationLevel -= 1
        formatter.AppendLine(eventInfo.ToString())
    End Sub
End Class

Комментарии

Метод FormatToString предоставляет унифицированный формат для сведений о событиях, который полезен, если данные события должны быть зарегистрированы, а затем представлены пользователю. Он вызывается внутренне, когда поставщик вызывает один из ToString методов.

Примечание

При форматировании пользовательских сведений о событиях для отображения переопределите FormatToString метод, а не ToString метод . Это позволит избежать перезаписи или незаконного изменения конфиденциальной системной информации.

Применяется к