WebAuditEvent クラス
アセンブリ: System.Web (system.web.dll 内)


運用および操作の担当者は、ASP.NET Health Monitoring を使用して、配置されている Web アプリケーションを管理できます。System.Web.Management 名前空間には、アプリケーションの状態データをパッケージ化する状態イベント型、およびそのデータを処理するプロバイダ型が含まれます。また、状態イベント管理を支援するサポート型も含まれます。
WebAuditEvent クラスは、ASP.NET Health Monitoring の監査イベント クラスの派生元である基本クラスです。監査イベントは、Web アプリケーションにおけるセキュリティ関連操作に関する情報を生成し、監査操作ごとに正常終了およびエラーの両方の情報を提供します。
ASP.NET Health Monitoring system は、正常終了のイベントもエラーのイベントもどちらも監査できます。つまり、通常および異常の両方の状態についてアプリケーションを監視できます。既定では、エラーの監査イベントだけが記録されます。
ASP.NET では次の操作が監査され、正常終了またはエラーの状態監視監査イベントが生成されます。
-
ASP.NET アプリケーションのユーザーによるログインの実行。この監査の詳細については、「WebAuthenticationSuccessAuditEvent」および「WebSuccessAuditEvent」を参照してください。
-
セキュリティ関連イベント。たとえば、認証エラーやリソースへのアクセス エラーなど、各種セキュリティ関連イベントが該当します。これらのイベントのログは、アプリケーションに対する侵入または攻撃の調査に役立ちます。既定では、匿名ユーザーの承認エラーに対する監査サポートは提供されません。エラー イベントの監査の詳細については、「WebAuthenticationFailureAuditEvent」および「WebFailureAuditEvent」を参照してください。
-
ASP.NET アプリケーションが生成するカスタムイベント。カスタム イベントは、WebAuditEvent クラスとその派生クラスの機能を拡張することによって監査できます。
![]() |
---|
ほとんどの場合、ASP.NET 状態監視型は実装のまま使用でき、healthMonitoring 構成セクションに値を指定して ASP.NET Health Monitoring system を制御できます。状態監視型の派生として独自のイベントおよびプロバイダを作成することもできます。WebAuditEvent クラスの派生の例については、このトピックの例を参照してください。 |

WebAuditEvent クラスの派生としてカスタム監査イベントを作成する方法を次のコード例に示します。
Imports System Imports System.Text Imports System.Web Imports System.Web.Management ' Implements a custom WebAuditEvent class. Public Class SampleWebAuditEvent Inherits System.Web.Management.WebAuditEvent Private customCreatedMsg, customRaisedMsg As String ' Invoked in case of events identified only by their event code. Public Sub New(ByVal msg As String, ByVal eventSource As Object, _ ByVal eventCode As Integer) MyBase.New(msg, eventSource, eventCode) ' Perform custom initialization. customCreatedMsg = String.Format("Event created at: {0}", DateTime.Now.TimeOfDay.ToString()) End Sub 'New ' Invoked in case of events identified by their event code.and ' event detailed code. Public Sub New(ByVal msg As String, ByVal eventSource As Object, _ ByVal eventCode As Integer, ByVal detailedCode As Integer) MyBase.New(msg, eventSource, eventCode, detailedCode) ' Perform custom initialization. customCreatedMsg = String.Format("Event created at: {0}", _ DateTime.Now.TimeOfDay.ToString()) End Sub 'New ' Raises the SampleWebAuditEvent. Public Overrides Sub Raise() ' Perform custom processing. customRaisedMsg = String.Format("Event raised at: {0}", _ DateTime.Now.TimeOfDay.ToString()) ' Raise the event. WebBaseEvent.Raise(Me) End Sub 'Raise ' Obtains the current thread information. Public Function GetRequestInformation() As WebRequestInformation ' Obtain the Web request information. ' No customization is allowed here. Return RequestInformation End Function 'GetRequestInformation 'Formats Web request event information. 'This method is invoked indirectly by the provider ' using one of the overloaded ToString() methods. Public Overrides Sub FormatCustomEventDetails(ByVal formatter As WebEventFormatter) MyBase.FormatCustomEventDetails(formatter) ' Add custom data. formatter.AppendLine("") formatter.IndentationLevel += 1 formatter.AppendLine("******** SampleWebAuditEvent Information Start ********") formatter.AppendLine(String.Format("Request path: {0}", RequestInformation.RequestPath)) formatter.AppendLine(String.Format("Request Url: {0}", RequestInformation.RequestUrl)) ' Display custom event timing. formatter.AppendLine(customCreatedMsg) formatter.AppendLine(customRaisedMsg) formatter.AppendLine("******** SampleWebAuditEvent Information End ********") formatter.IndentationLevel -= 1 End Sub 'FormatCustomEventDetails End Class 'SampleWebAuditEvent
using System; using System.Text; using System.Web; using System.Web.Management; namespace SamplesAspNet { // Implements a custom WebAuditEvent class. public class SampleWebAuditEvent : System.Web.Management.WebAuditEvent { private string customCreatedMsg, customRaisedMsg; // Invoked in case of events identified only by their event code. public SampleWebAuditEvent(string msg, object eventSource, int eventCode): base(msg, eventSource, eventCode) { // Perform custom initialization. customCreatedMsg = string.Format("Event created at: {0}", DateTime.Now.TimeOfDay.ToString()); } // Invoked in case of events identified by their event code.and // event detailed code. public SampleWebAuditEvent(string msg, object eventSource, int eventCode, int detailedCode): base(msg, eventSource, eventCode, detailedCode) { // Perform custom initialization. customCreatedMsg = string.Format("Event created at: {0}", DateTime.Now.TimeOfDay.ToString()); } // Raises the SampleWebAuditEvent. public override void Raise() { // Perform custom processing. customRaisedMsg = string.Format("Event raised at: {0}", DateTime.Now.TimeOfDay.ToString()); // Raise the event. WebBaseEvent.Raise(this); } // Obtains the current thread information. public WebRequestInformation GetRequestInformation() { // Obtain the Web request information. // No customization is allowed here. return RequestInformation; } //Formats Web request event information. //This method is invoked indirectly by the provider // using one of the overloaded ToString() methods. public override void FormatCustomEventDetails( WebEventFormatter formatter) { base.FormatCustomEventDetails(formatter); // Add custom data. formatter.AppendLine(""); formatter.IndentationLevel += 1; formatter.AppendLine( "******** SampleWebAuditEvent Information Start ********"); formatter.AppendLine(string.Format("Request path: {0}", RequestInformation.RequestPath)); formatter.AppendLine(string.Format("Request Url: {0}", RequestInformation.RequestUrl)); // Display custom event timing. formatter.AppendLine(customCreatedMsg); formatter.AppendLine(customRaisedMsg); formatter.AppendLine( "******** SampleWebAuditEvent Information End ********"); formatter.IndentationLevel -= 1; } } }
次に示すのは、ASP.NET でイベントを使用できるようにする構成ファイルの抜粋です。
<healthMonitoring
</healthMonitoring>

System.Web.Management.WebBaseEvent
System.Web.Management.WebManagementEvent
System.Web.Management.WebAuditEvent
System.Web.Management.WebFailureAuditEvent
System.Web.Management.WebSuccessAuditEvent


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- WebAuditEvent クラスのページへのリンク