WebApplicationInformation 클래스

정의

상태 이벤트와 관련된 정보를 제공합니다.

public ref class WebApplicationInformation sealed
public sealed class WebApplicationInformation
type WebApplicationInformation = class
Public NotInheritable Class WebApplicationInformation
상속
WebApplicationInformation

예제

다음 코드 예제에는 두 부분이 있습니다. 첫 번째 부분은 ASP.NET 사용자 지정 이벤트를 사용할 수 있도록 하는 구성 파일의 발췌입니다. 두 번째는 클래스를 사용하여 WebApplicationInformation 해당 사용자 지정 이벤트를 만드는 방법을 보여줍니다.

사용자 지정 이벤트가 적절한 시간에 발생하는지 확인합니다. 즉, 대체되는 동일한 시스템 상태 이벤트가 발생할 때 발생합니다.

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

  <eventMappings>
    <add name="SampleApplicationInformation"
        type="SamplesAspNet.SampleWebApplicationInformation, webapplicationinformation, Version=1.0.1585.27289, Culture=neutral, PublicKeyToken=3648e5c763a8239f, processorArchitecture=MSIL"/>
  </eventMappings>

  <rules>
    <add name="Custom Application Information"
      eventName="SampleApplicationInformation"
      provider="EventLogProvider"
      profile="Default"/>
</rules>

</healthMonitoring>
using System;
using System.Text;
using System.Web;
using System.Web.Management;

namespace SamplesAspNet
{
    // Implements a custom WebBaseEvent that uses
    // WebApplicationInformation.
    public class SampleWebApplicationInformation :
        WebBaseEvent
    {
        private StringBuilder eventInfo;

        // Instantiate SampleWebGet    
        public SampleWebApplicationInformation(string msg,
            object eventSource, int eventCode):
        base(msg, eventSource, eventCode)
        {
            
            // Perform custom initialization.
            eventInfo = new StringBuilder();
            eventInfo.Append(string.Format(
                "Event created at: {0}",
                EventTime.ToString()));
        }

        // Raises the event.
        public override void Raise()
        {
            // Perform custom processing. 
            eventInfo.Append(string.Format(
            "Event raised at: {0}",
            EventTime.ToString()));

            // Raise the event.
            base.Raise();
        }
        public string GetApplicationDomain()
        {
            // Get the name of the application domain.
            return (string.Format(
                "Application domain: {0}",
                ApplicationInformation.ApplicationDomain));
        }
        public string GetApplicationPath()
        {
            // Get the name of the application  path.
            return (string.Format(
                "Application path: {0}",
                ApplicationInformation.ApplicationPath));
        }
        public string GetApplicationVirtualPath()
        {
            // Get the name of the application virtual path.
            return (string.Format(
                "Application virtual path: {0}",
                ApplicationInformation.ApplicationVirtualPath));
        }
        public string GetApplicationMachineName()
        {
            // Get the name of the application machine name.
            return (string.Format(
                "Application machine name: {0}",
                ApplicationInformation.MachineName));
        }
        public string GetApplicationTrustLevel()
        {
            // Get the name of the application trust level.
            return (string.Format(
                "Application trust level: {0}",
                ApplicationInformation.TrustLevel));
        }
        //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());
        }
    }
}
Imports System.Text
Imports System.Web
Imports System.Web.Management


'Implements a custom WebBaseEvent that uses
' WebApplicationInformation. 
Public Class SampleWebApplicationInformation
    Inherits WebBaseEvent
    Private eventInfo As StringBuilder


    ' Instantiate SampleWebGet    
    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: {0}", EventTime.ToString()))
    End Sub


    ' Raises the event.
    Public Overrides Sub Raise()
        ' Perform custom processing. 
        eventInfo.Append(String.Format( _
        "Event raised at: {0}", EventTime.ToString()))

        ' Raise the event.
        MyBase.Raise()
    End Sub

    Public Function GetApplicationDomain() As String
        ' Get the name of the application domain.
        Return String.Format( _
        "Application domain: {0}", _
        ApplicationInformation.ApplicationDomain)
    End Function 'GetApplicationDomain

    Public Function GetApplicationPath() As String
        ' Get the name of the application  path.
        Return String.Format( _
        "Application path: {0}", _
        ApplicationInformation.ApplicationPath())
    End Function 'GetApplicationPath

    Public Function GetApplicationVirtualPath() As String
        ' Get the name of the application virtual path.
        Return String.Format( _
        "Application virtual path: {0}", _
        ApplicationInformation.ApplicationVirtualPath())
    End Function 'GetApplicationVirtualPath

    Public Function GetApplicationMachineName() As String
        ' Get the name of the application machine name.
        Return String.Format( _
        "Application machine name: {0}", _
        ApplicationInformation.MachineName())
    End Function 'GetApplicationMachineName

    Public Function GetApplicationTrustLevel() As String
        ' Get the name of the application trust level.
        Return String.Format( _
        "Application trust level: {0}", _
        ApplicationInformation.TrustLevel())
    End Function 'GetApplicationTrustLevel

    '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
End Class

설명

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

클래스의 WebApplicationInformation 인스턴스에는 형식에서 WebManagementEvent 파생된 형식을 사용하여 얻은 정보가 포함됩니다.

이 형식에서 제공하는 보호된 정보에 액세스하려면 애플리케이션에 적절한 권한이 필요합니다.

다음은 ASP.NET 애플리케이션 정보가 포함된 오류 이벤트를 기록할 수 있도록 하는 데 사용할 수 있는 구성 파일의 발췌입니다.

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

    <rules>
     <add
       name="All Errors Default"
       eventName="All Errors"
       provider="EventLogProvider"
       profile="Default"
       minInterval="00:01:00" />
    </rules>

</healthMonitoring>

메모

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

속성

Name Description
ApplicationDomain

현재 애플리케이션 도메인 이름을 가져옵니다.

ApplicationPath

애플리케이션 물리적 경로를 가져옵니다.

ApplicationVirtualPath

애플리케이션 논리 경로를 가져옵니다.

MachineName

애플리케이션 컴퓨터 이름을 가져옵니다.

TrustLevel

애플리케이션 신뢰 수준을 가져옵니다.

메서드

Name Description
Equals(Object)

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

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

애플리케이션 정보의 형식을 지정합니다.

GetHashCode()

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

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

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

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

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

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

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

적용 대상

추가 정보