WebManagementEvent Klasa
Definicja
Ważny
Niektóre informacje dotyczą produktów przedpremierowych, które mogą zostać znacznie zmodyfikowane przed premierą. Microsoft nie udziela żadnych gwarancji, ani wyraźnych, ani domniemanych, dotyczących informacji podanych tutaj.
Definiuje klasę bazową dla zdarzeń, które przenoszą informacje o aplikacji i przetwarzaniu.
public ref class WebManagementEvent : System::Web::Management::WebBaseEvent
public class WebManagementEvent : System.Web.Management.WebBaseEvent
type WebManagementEvent = class
inherit WebBaseEvent
Public Class WebManagementEvent
Inherits WebBaseEvent
- Dziedziczenie
- Pochodny
Przykłady
W poniższym przykładzie pokazano, jak zaimplementować zdarzenie niestandardowe, wyprowadzając je z WebManagementEvent klasy .
using System;
using System.Text;
using System.Web;
using System.Web.Management;
namespace Samples.AspNet.Management
{
// Implements a custom
// WebManagementEvent class.
public class SampleWebManagementEvent :
WebManagementEvent
{
private StringBuilder eventInfo;
// Invoked in case of events
// identified only by their event code.
public SampleWebManagementEvent(string msg,
object eventSource, int eventCode):
base(msg, eventSource, eventCode)
{
// Perform custom initialization.
eventInfo = new StringBuilder();
eventInfo.Append(string.Format(
"Event created at: ",
EventTime.ToString()));
}
// Invoked in case of events identified
// by their event code.and related
// event detailed code.
public SampleWebManagementEvent(string msg,
object eventSource, int eventCode,
int eventDetailCode):
base(msg, eventSource,
eventCode, eventDetailCode)
{
// Perform custom initialization.
eventInfo = new StringBuilder();
eventInfo.Append(string.Format(
"Event created at: ",
EventTime.ToString()));
}
// Raises the SampleWebRequestEvent.
public override void Raise()
{
// Perform custom processing.
eventInfo.Append(string.Format(
"Event raised at: ",
EventTime.ToString()));
// Raise the event.
base.Raise();
}
// Obtains the current process information.
public string GetProcessInfo()
{
StringBuilder tempPi = new StringBuilder();
WebProcessInformation pi = ProcessInformation;
tempPi.Append(
pi.ProcessName + Environment.NewLine);
tempPi.Append(
pi.ProcessID.ToString() + Environment.NewLine);
tempPi.Append(
pi.AccountName + Environment.NewLine);
return tempPi.ToString();
}
public override void FormatCustomEventDetails(
WebEventFormatter formatter)
{
base.FormatCustomEventDetails(formatter);
// Add custom data.
formatter.AppendLine("");
formatter.IndentationLevel += 1;
formatter.AppendLine(
"** SampleWebManagementEvent Start **");
// Add custom data.
formatter.AppendLine(eventInfo.ToString());
formatter.AppendLine(
"** SampleWebManagementEvent End **");
}
}
}
Imports System.Text
Imports System.Web
Imports System.Web.Management
' Implements a custom
' WebManagementEvent class.
Public Class SampleWebManagementEvent
Inherits WebManagementEvent
Private eventInfo As StringBuilder
' 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.
eventInfo = New StringBuilder()
eventInfo.Append(String.Format( _
"Event created at: ", EventTime.ToString()))
End Sub
' Invoked in case of events identified
' by their event code.and related
' event detailed code.
Public Sub New(ByVal msg As String, _
ByVal eventSource As Object, _
ByVal eventCode As Integer, _
ByVal eventDetailCode As Integer)
MyBase.New(msg, eventSource, _
eventCode, eventDetailCode)
' Perform custom initialization.
eventInfo = New StringBuilder()
eventInfo.Append(String.Format( _
"Event created at: ", EventTime.ToString()))
End Sub
' Raises the SampleWebRequestEvent.
Public Overrides Sub Raise()
' Perform custom processing.
eventInfo.Append(String.Format( _
"Event raised at: ", EventTime.ToString()))
' Raise the event.
MyBase.Raise()
End Sub
' Obtains the current process information.
Public Function GetProcessInfo() As String
Dim tempPi As New StringBuilder()
Dim pi As WebProcessInformation = ProcessInformation
tempPi.Append( _
(pi.ProcessName + Environment.NewLine))
tempPi.Append( _
(pi.ProcessID.ToString() + Environment.NewLine))
tempPi.Append( _
(pi.AccountName + Environment.NewLine))
Return tempPi.ToString()
End Function 'GetProcessInfo
Public Overrides Sub FormatCustomEventDetails( _
ByVal formatter As WebEventFormatter)
MyBase.FormatCustomEventDetails(formatter)
' Add custom data.
formatter.AppendLine("")
formatter.IndentationLevel += 1
formatter.AppendLine( _
"** SampleWebManagementEvent Start **")
' Add custom data.
formatter.AppendLine(eventInfo.ToString())
formatter.AppendLine( _
"** SampleWebManagementEvent End **")
End Sub
End Class
Poniżej znajduje się fragment pliku konfiguracji, który umożliwia ASP.NET używanie zdarzenia niestandardowego.
<healthMonitoring enabled="true"
heartBeatInterval="0">
<eventMappings>
<add name="SampleWebManagementEvent" type="SamplesAspNet.SampleWebManagementEvent,webmanagementevent,Version=1.0.1573.24438, Culture=neutral, PublicKeyToken=2f5f337ae5c9bdaa, processorArchitecture=MSIL"/>
</eventMappings>
<rules>
<add
name="Custom WebManagementEvent"
eventName="SampleWebManagementEvent"
provider="EventLogProvider"
profile="Critical"/>
</rules>
</healthMonitoring>
Uwagi
ASP.NET monitorowanie kondycji umożliwia pracownikom produkcyjnym i operacyjnym zarządzanie wdrożonych aplikacji internetowych. System.Web.Management Przestrzeń nazw zawiera typy zdarzeń kondycji odpowiedzialnych za pakowanie danych o stanie kondycji aplikacji i typów dostawców odpowiedzialnych za przetwarzanie tych danych. Zawiera również typy pomocnicze, które ułatwiają zarządzanie zdarzeniami kondycji.
Jest WebManagementEvent to klasa bazowa dla wszystkich typów zdarzeń monitorowania kondycji ASP.NET. Używa klasy do uzyskiwania WebProcessInformation informacji o procesie, które są dostępne dla jej klas pochodnych.
Uwaga
W większości przypadków będzie można użyć ASP.NET typów monitorowania kondycji zgodnie z implementacją i będziesz kontrolować system monitorowania kondycji, określając wartości w healthMonitoring sekcji konfiguracji. Możesz również pochodzić z typów monitorowania kondycji, aby utworzyć własne niestandardowe zdarzenia i dostawców. Przykład wyprowadzania z klasy można znaleźć w przykładzie WebManagementEvent podanym w tym temacie.
Notatki dla spadkobierców
Podczas formatowania niestandardowych informacji o zdarzeniach do wyświetlania przesłoń metodę FormatCustomEventDetails(WebEventFormatter) , a nie metodę ToString . Pozwoli to uniknąć zastępowania lub manipulowania poufnymi informacjami systemowymi.
Kod zdarzenia określony dla zdarzenia niestandardowego musi być większy niż WebExtendedBase.
Konstruktorów
| Nazwa | Opis |
|---|---|
| WebManagementEvent(String, Object, Int32, Int32) |
Inicjuje WebManagementEvent nowe wystąpienie klasy przy użyciu podanych parametrów. |
| WebManagementEvent(String, Object, Int32) |
Inicjuje WebManagementEvent nowe wystąpienie klasy przy użyciu podanych parametrów. |
Właściwości
| Nazwa | Opis |
|---|---|
| EventCode |
Pobiera wartość kodu skojarzona ze zdarzeniem. (Dziedziczone od WebBaseEvent) |
| EventDetailCode |
Pobiera kod szczegółów zdarzenia. (Dziedziczone od WebBaseEvent) |
| EventID |
Pobiera identyfikator skojarzony ze zdarzeniem. (Dziedziczone od WebBaseEvent) |
| EventOccurrence |
Pobiera licznik reprezentujący liczbę przypadków wystąpienia zdarzenia. (Dziedziczone od WebBaseEvent) |
| EventSequence |
Pobiera liczbę przypadków zgłoszenia zdarzenia przez aplikację. (Dziedziczone od WebBaseEvent) |
| EventSource |
Pobiera obiekt, który zgłasza zdarzenie. (Dziedziczone od WebBaseEvent) |
| EventTime |
Pobiera czas zgłoszenia zdarzenia. (Dziedziczone od WebBaseEvent) |
| EventTimeUtc |
Pobiera czas zgłoszenia zdarzenia. (Dziedziczone od WebBaseEvent) |
| Message |
Pobiera komunikat opisujący zdarzenie. (Dziedziczone od WebBaseEvent) |
| ProcessInformation |
Pobiera informacje o ASP.NET procesie hostingu aplikacji. |
Metody
| Nazwa | Opis |
|---|---|
| Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt. (Dziedziczone od Object) |
| FormatCustomEventDetails(WebEventFormatter) |
Zapewnia standardowe formatowanie informacji o zdarzeniu. (Dziedziczone od WebBaseEvent) |
| GetHashCode() |
Służy jako domyślna funkcja skrótu. (Dziedziczone od Object) |
| GetType() |
Type Pobiera wartość bieżącego wystąpienia. (Dziedziczone od Object) |
| IncrementPerfCounters() |
Używane wewnętrznie do zwiększenia liczników wydajności. (Dziedziczone od WebBaseEvent) |
| MemberwiseClone() |
Tworzy płytkią kopię bieżącego Objectelementu . (Dziedziczone od Object) |
| Raise() |
Zgłasza zdarzenie, powiadamiając każdego skonfigurowanego dostawcę o wystąpieniu zdarzenia. (Dziedziczone od WebBaseEvent) |
| ToString() |
Formatuje informacje o zdarzeniach do celów wyświetlania. (Dziedziczone od WebBaseEvent) |
| ToString(Boolean, Boolean) |
Formatuje informacje o zdarzeniach do celów wyświetlania. (Dziedziczone od WebBaseEvent) |