Web Events - Output Events to SQL Server Database, Windows Event Log, WMI Namespace or Email

xiaoxiao2021-03-30  216

The web event web event feature provides a general-purpose framework for issuing runtime events to indicate the worthwhile operations that occur in the application, report the application health or any other information worth noting. This feature enables administrators to determine the events they are interested in through the configuration, and specify which channel transfer passes. This feature includes a variety of ready-to-use channel providers that apply to different scenarios: save events to Microsoft? SQL Server Send event reports via email to write events to Windows? Event log via WMI forwarding event ASP.NET 2.0 itself Also use web event features to provide health report, review, and detection of various runtime functions. Anyone can develop and trigger a custom event type to further detect their applications.

In the following example, the application is configured to send all sent Web events to the SQL Server provider. This page will initiate an instance of custom event types from WebEventBase, and read events directly from the SQL Server event table using the data source control. The GridView that displays the event list also shows some events that ASP.NET generated in the request processing cycle.

C # Health Monitoring Events Event and Event Provider Web Events are instances of various web event base classes constructed at the corresponding information, and specify event code / detailed information code, which can be used to identify the event to be represented. Happening. ASP.NET has a set of base classes for detecting a variety of situations that caused in the infrastructure, and it allows applications to extend these base classes with custom event classes, which indicate any of the application selection report. information. These custom events can then be created and raised by the application code through the web event engine.

The ASP.NET contains the following web event base classes (not all listed), which are located in System.Web.Management namespace:

Function Description The event base class for all events of WebBaseEvent. Contains all events necessary, such as event code, event detail code, date and time, serial number, event message, and event details. WebManageMENTEVENT Management Event Basic class, such as application survival, request, error, and audit event. WebHeartBeaTevent is generated by the application at a fixed time intervals to capture useful runtime status information. The base class of the WebAuditEvent Security audit event is used to mark the failed, decryption failure, etc. WebRequestEvent All information request events are based on the base class. WebBaseerRorEvent All items that indicate erroneous events.

When the event is triggered, they are processed by the web event engine that routes these events to one or more web event providers that represent event users, and event users are configured to listen to specific events in monitoring operations. . The Web event engine also provides some other services, such as current limiting events to avoid unbearable events.

Provincial providers in the web event are actually pluggable event users. ASP.NET 2.0 provides a wide range of ready-to-use built-in providers and enables you to implement and configure your own custom provider. The included providers can output events to Microsoft SQL Server databases, Windows event logs, WMI namespaces or email output events. Configuration Event Note: In this section, all configurations are elements in the design (unless otherwise stated).

In order to receive an event, you need to create a subscription to map the event set to the event user, which is implemented by the web event provider. Subscribe has the following parts:

Event mapping. Used to define an event set and the name that can be used to reference the event set in the subscription, identify the event set through an event base class and an optional event code, and all events in this event must be derived from the event base. class. For example, the following mapping creates an event set, which contains all audit events from 0 to 1000:

Event subscription rules. The mapping between the event set and the web event provider that will handle the event set. This rule can also select a configuration file that contains event current limiting information to limit the amount of event processing, or specify these settings directly.

For example, the following rules send us ahead of the audit event set to the default event log provider installed with ASP.NET 2.0 in front of the audit set.:

Provider. Used to define the provider of event channels that will use events. Here, you can configure one of the default providers contained in ASP.NET 2.0, or specify your own derived from the web event provider base class.

For example, the following configuration exists in the ASP.NET 2.0 installation by default, so that the ASP.NET event log provider can write events to Windows event logs:

You can also configure other settings to further control the behavior of web events in the festival, such as setting configuration files to specify current limiting settings applied to rules, and buffer mode for buffering providers. Creating a Custom Event To create a custom event type, you must derive your own event class from a derived web event class class. The instance of this event can then be created and triggered at runtime, and the subscription to the event is configured as described above.

The following example creates a custom event using a custom event code and message, and an instance of this event will be triggered in the page event handler: // in the code directory, or your application sol

Class MySampleEvent: System.Web.Management.WebbaseEvent

{

Public const Int mysampleEventcode = 200001;

Public mysampleEvent (String Message): Base (Message, Null, MySampleEventcode) {}

}

// in an ASPX Page

Void Page_Load ()

{

// Create an instance of the event

MySampleEvent E = New MySampleEvent ("IN PAGE_LOAD ()");

// raise the Event to the Web Event Enginee.raise ();

}

Detection Applications In order to detect an application for runtime monitoring, you should create a custom event class that is sent from the correct web event class, and contains additional information that makes sense to the application. You can then create and trigger instances of these events in the code you want to detect.

After the application or the internal creation of its components, you can configure event subscriptions to send a particular event to the appropriate provider through the channel. Event current limiting event current limiting refers to the rate of restricting event incoming providers to avoid overburning over the provider, or limit the output of the event to transmit, process, store, or display events. The current limiting setting is applied to the rule level.

You can specify a current limiting setting based on each rule or create a configuration file defining a set of current stream settings to limit the event. You can use the current limiting capabilities that you can use to record only the N times, only one event is recorded in a given period, or only the first N times a given event occurs.

The following example modifies the audit event subscription rules to ensure maximum event rate is an event per second:

Note: The limit will lose the event, so be careful when setting the current limiting settings for sensitive events such as audit events. A limited-limiting alternative is to use a buffer feature of a particular provider that is transmitted as a delay event to avoid loss events.

The following example places the current limiting setting in a configuration file, which can then share between multiple rules:

转载请注明原文地址:https://www.9cbs.com/read-130586.html

New Post(0)