Freigeben über


WebApplicationInformation.FormatToString(WebEventFormatter) Methode

Definition

Formatiert die Anwendungsinformationen.

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)

Parameter

formatter
WebEventFormatter

Der WebEventFormatter, der die Tabstopp- und Einzugseinstellungen enthält, die zum Formatieren der Informationen über Websystemereignisse verwendet werden.

Beispiele

Im folgenden Codebeispiel wird gezeigt, wie benutzerdefinierte Informationen formatiert werden.

//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

Hinweise

Die FormatToString -Methode stellt ein einheitliches Format für Ereignisinformationen bereit, das nützlich ist, wenn die Ereignisdaten protokolliert und später dem Benutzer angezeigt werden müssen. Sie wird intern aufgerufen, wenn der Anbieter eine der ToString Methoden aufruft.

Hinweis

Wenn Sie ihre benutzerdefinierten Ereignisinformationen für die Anzeige formatieren, überschreiben Sie die FormatToString -Methode und nicht die ToString -Methode. Dadurch wird verhindert, dass vertrauliche Systeminformationen überschrieben oder manipuliert werden.

Gilt für: