Partage via


WebApplicationInformation.FormatToString(WebEventFormatter) Méthode

Définition

Met en forme les informations d'application.

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)

Paramètres

formatter
WebEventFormatter

WebEventFormatter qui contient les paramètres de tabulation et de mise en retrait utilisés pour mettre en forme les informations d’événements d’intégrité web.

Exemples

L’exemple de code suivant montre comment mettre en forme des informations personnalisées.

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

Remarques

La FormatToString méthode fournit un format uniforme pour les informations d’événement, ce qui est utile si les données d’événement doivent être journalisées et présentées ultérieurement à l’utilisateur. Il est appelé en interne lorsque le fournisseur appelle l’une des ToString méthodes.

Notes

Lors de la mise en forme de vos informations d’événement personnalisées pour l’affichage, remplacez la FormatToString méthode plutôt que la ToString méthode. Cela évitera de remplacer ou de falsification des informations système sensibles.

S’applique à