WebApplicationLifetimeEvent 클래스

정의

애플리케이션의 수명 동안 중요한 이벤트를 나타냅니다.

public ref class WebApplicationLifetimeEvent : System::Web::Management::WebManagementEvent
public class WebApplicationLifetimeEvent : System.Web.Management.WebManagementEvent
type WebApplicationLifetimeEvent = class
    inherit WebManagementEvent
Public Class WebApplicationLifetimeEvent
Inherits WebManagementEvent
상속
WebApplicationLifetimeEvent

예제

다음 코드 예제에서는 클래스에서 WebApplicationLifetimeEvent 파생하여 사용자 지정 이벤트를 만드는 방법을 보여줍니다.


using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
  // Implements a custom WebManagementEvent class. 
    public class SampleWebApplicationLifetimeEvent :
        System.Web.Management.WebApplicationLifetimeEvent
    {
        private string customCreatedMsg, customRaisedMsg;

        // Invoked in case of events identified only by 
        // their event code.
        public SampleWebApplicationLifetimeEvent(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 related event detailed code.
        public SampleWebApplicationLifetimeEvent(string msg, 
            object eventSource, int eventCode, 
            int eventDetailCode):
          base(msg, eventSource, eventCode, eventDetailCode)
        {
            // Perform custom initialization.
            customCreatedMsg =
             string.Format("Event created at: {0}",
             DateTime.Now.TimeOfDay.ToString());
        }


        // Raises the SampleWebRequestEvent.
        public override void Raise()
        {
            // Perform custom processing. 
            customRaisedMsg = string.Format(
                "Event raised at: {0}\n", 
                DateTime.Now.TimeOfDay.ToString());
            // Raise the event.
            base.Raise();
        }

        //Formats Web request event information.
        public override void FormatCustomEventDetails(
            WebEventFormatter formatter)
        {
            base.FormatCustomEventDetails(formatter);

            // Add custom data.
            formatter.AppendLine("");

            formatter.IndentationLevel += 1;
    
            formatter.TabSize = 4;
       
            formatter.AppendLine(
                 "*SampleWebApplicationLifetimeEvent Start *");
            formatter.AppendLine("Custom information goes here");
            formatter.AppendLine(
                "* SampleWebApplicationLifetimeEvent End *");
            // Display custom event timing.
            formatter.AppendLine(customCreatedMsg);
            formatter.AppendLine(customRaisedMsg);
        
            formatter.IndentationLevel -= 1;
        }
    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management


' Implements a custom WebManagementEvent class. 

Public Class SampleWebApplicationLifetimeEvent
    Inherits System.Web.Management.WebApplicationLifetimeEvent
    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
    
    
    ' 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.
        customCreatedMsg = _
        String.Format("Event created at: {0}", _
        DateTime.Now.TimeOfDay.ToString())
    End Sub


    ' Raises the SampleWebRequestEvent.
    Public Overrides Sub Raise() 
        ' Perform custom processing. 
        customRaisedMsg = _
        String.Format("Event raised at: {0}" + _
        vbLf, DateTime.Now.TimeOfDay.ToString())
        ' Raise the event.
        MyBase.Raise()
    
    End Sub
    
    'Formats Web request event information.
    Public Overrides Sub FormatCustomEventDetails( _
    ByVal formatter As WebEventFormatter)
        MyBase.FormatCustomEventDetails(formatter)

        ' Add custom data.
        formatter.AppendLine("")

        formatter.IndentationLevel += 1

        formatter.TabSize = 4

        formatter.AppendLine( _
        "*SampleWebApplicationLifetimeEvent Start *")
        formatter.AppendLine("Custom information goes here")
        formatter.AppendLine( _
        "* SampleWebApplicationLifetimeEvent End *")
        ' Display custom event timing.
        formatter.AppendLine(customCreatedMsg)
        formatter.AppendLine(customRaisedMsg)

        formatter.IndentationLevel -= 1

    End Sub
End Class

다음 구성 파일 발췌에서는 위에서 정의한 healthMonitoring 코드를 ASP.NET 상태 모니터링 시스템에 추가하도록 구성 파일의 SampleWebApplicationLifetimeEvent 섹션을 구성하는 방법을 보여 줍니다. 시스템에 이벤트를 추가하려면 섹션에 새 항목을 추가하여 이벤트를 정의하고 섹션에 새 항목을 eventMappings 추가하여 이벤트를 공급자에 rules 매핑해야 합니다.

<healthMonitoring
  enabled="true"
  heartBeatInterval="0">

    <eventMappings>
       <clear />
       <!-- Configure the application lifetime event -->
       <!-- object to handle the Web application events. -->
       <add name="SampleApplicationLifetimeEvents"
         type="System.Web.Management.SampleWebApplicationLifetimeEvent,
         System.Web,Version=2.0.3600.0,
         Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
     </eventMappings>

    <rules>
      <clear/>
       // Configure the connection between the
       // application lifetime event object
       // and the provider that must process it.
       <add name="Custom Application Events"
         eventName="SampleApplicationLifetimeEvents"
         provider="EventLogProvider"
         profile="Default"
         minInterval="00:01:00" />
    </rules>

</healthMonitoring>

설명

ASP.NET 상태 모니터링을 사용하면 프로덕션 및 운영 직원이 배포된 웹 애플리케이션을 관리할 수 있습니다. 네임스페이스에는 System.Web.Management 애플리케이션 상태 데이터 패키징을 담당하는 상태 이벤트 유형과 이 데이터 처리를 담당하는 공급자 유형이 포함됩니다. 또한 상태 이벤트를 관리하는 동안 도움이 되는 지원 유형도 포함합니다.

애플리케이션 수명 이벤트에는 애플리케이션 시작 및 종료 이벤트와 같은 이벤트가 포함됩니다. 애플리케이션이 종료된 경우 관련 이벤트 메시지 필드를 확인하여 이유를 확인할 수 있습니다.

WebApplicationLifetimeEvent 인스턴스가 발생하면 ASP.NET 상태 모니터링이 애플리케이션 수명 이벤트 성능 카운터를 업데이트합니다. 다음 예제와 같이 구성 파일 섹션의 하위 섹션에 WebApplicationLifetimeEvent 개체 rules 를 추가하여 healthMonitoring 이러한 이벤트를 기록할 수 있습니다.

<rules>
  <add name="Application Events"
    eventName="Application Lifetime Events"
    provider="EventLogProvider"
    profile="Default"
    minInterval="00:01:00" />
</rules>

애플리케이션 수명 이벤트 성능 카운터에는 모든 ASP.NET 수명 이벤트의 합계가 포함됩니다. 시스템 모니터(PerfMon)에서 이 성능 카운터를 보려면 Add Counters 창의 ASP.NET> 드롭다운 목록에서 ASP.NET를 선택합니다. 애플리케이션 수명 이벤트 성능 카운터를 선택하고 추가 단추를 클릭합니다. 자세한 내용은 MSDN에서 "ASP.NET 애플리케이션과 함께 시스템 모니터(PerfMon) 사용"을 참조하세요. 표준 EventLogWebEventProvider 의해 이벤트를 기록하도록 허용하는 경우 이벤트 뷰어에서 Application 로그를 선택하여 이벤트를 볼 수 있습니다.

Caution

개체는 WebApplicationLifetimeEvent 대용량 이벤트이므로 로깅은 리소스를 많이 사용하며 시스템 속도가 느려질 수 있습니다. 또한 이벤트 양이 많고 이벤트 로깅이 작동하는 방식으로 인해 클래스의 EventLogWebEventProvider 경우 다른 이벤트를 덮어쓸 수도 있습니다.

메모

대부분의 경우 구현된 ASP.NET 상태 모니터링 유형을 사용할 수 있으며 healthMonitoring 구성 섹션에서 값을 지정하여 상태 모니터링 시스템을 제어합니다. 상태 모니터링 형식에서 파생하여 고유한 사용자 지정 이벤트 및 공급자를 만들 수도 있습니다. 클래스에서 파생되는 예제는 WebApplicationLifetimeEvent 이 항목에 제공된 예제를 참조하세요.

상속자 참고

표시할 사용자 지정 이벤트 정보의 서식을 지정할 때 메서드 대신 메서드를 재정의 FormatCustomEventDetails(WebEventFormatter)ToString 합니다. 이렇게 하면 중요한 시스템 정보를 덮어쓰거나 변조하지 않습니다.

생성자

Name Description
WebApplicationLifetimeEvent(String, Object, Int32, Int32)

제공된 매개 변수를 WebApplicationLifetimeEvent 사용하여 클래스를 초기화합니다.

WebApplicationLifetimeEvent(String, Object, Int32)

제공된 매개 변수를 WebApplicationLifetimeEvent 사용하여 클래스를 초기화합니다.

속성

Name Description
EventCode

이벤트와 연결된 코드 값을 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventDetailCode

이벤트 세부 정보 코드를 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventID

이벤트와 연결된 식별자를 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventOccurrence

이벤트가 발생한 횟수를 나타내는 카운터를 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventSequence

애플리케이션에서 이벤트가 발생한 횟수를 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventSource

이벤트를 발생시키는 개체를 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventTime

이벤트가 발생한 시간을 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
EventTimeUtc

이벤트가 발생한 시간을 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
Message

이벤트를 설명하는 메시지를 가져옵니다.

(다음에서 상속됨 WebBaseEvent)
ProcessInformation

ASP.NET 애플리케이션 호스팅 프로세스에 대한 정보를 가져옵니다.

(다음에서 상속됨 WebManagementEvent)

메서드

Name Description
Equals(Object)

지정된 개체가 현재 개체와 같은지 여부를 확인합니다.

(다음에서 상속됨 Object)
FormatCustomEventDetails(WebEventFormatter)

이벤트 정보의 표준 서식을 제공합니다.

(다음에서 상속됨 WebBaseEvent)
GetHashCode()

기본 해시 함수로 사용됩니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type 가져옵니다.

(다음에서 상속됨 Object)
IncrementPerfCounters()

성능 카운터를 증가시키려면 내부적으로 사용됩니다.

MemberwiseClone()

현재 Object단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Raise()

구성된 공급자에게 이벤트가 발생했음을 알려 이벤트를 발생합니다.

(다음에서 상속됨 WebBaseEvent)
ToString()

표시를 위해 이벤트 정보의 형식을 지정합니다.

(다음에서 상속됨 WebBaseEvent)
ToString(Boolean, Boolean)

표시를 위해 이벤트 정보의 형식을 지정합니다.

(다음에서 상속됨 WebBaseEvent)

적용 대상

추가 정보