WebApplicationInformation.FormatToString メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As WebApplicationInformation Dim formatter As WebEventFormatter instance.FormatToString(formatter)

FormatToString メソッドを使用すると、イベント情報の形式を統一できます。イベント データのログを記録しておき、後でユーザーに提示する場合に有用です。このメソッドは、プロバイダが ToString メソッドのどれかを呼び出したときに内部的に呼び出されます。
![]() |
---|
カスタム イベント情報を表示用に書式設定する場合は、ToString メソッドではなく、FormatToString メソッドをオーバーライドします。これにより、重要なシステム情報に対する上書きや不正な変更を防げます。 |

カスタム情報を所定の形式にする方法を次のコード例に示します。
'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 'FormatCustomEventDetails End Class 'SampleWebApplicationInformation
//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()); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- WebApplicationInformation.FormatToString メソッドのページへのリンク