EventLogEntry 클래스

정의

이벤트 로그에 단일 레코드를 캡슐화합니다. 이 클래스는 상속할 수 없습니다.

public ref class EventLogEntry sealed : System::ComponentModel::Component, System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class EventLogEntry : System.ComponentModel.Component, System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type EventLogEntry = class
    inherit Component
    interface ISerializable
Public NotInheritable Class EventLogEntry
Inherits Component
Implements ISerializable
상속
특성
구현

예제

다음 코드 예제에서는 EventLogEntry 클래스의 사용을 보여 줍니다. 이 예제에서 문은 switch 콘솔 입력을 사용하여 지정된 이벤트 유형에 대한 이벤트 로그 항목을 검색합니다. 일치하는 항목이 발견되면 로그 항목 원본 정보가 콘솔에 표시됩니다.

using System;
using System.Diagnostics;
   class MyEventlogClass
   {
      public static void Main()
      {
         String myEventType=null;
         // Associate the instance of 'EventLog' with local System Log.
         EventLog myEventLog = new EventLog("System", ".");
         Console.WriteLine("1:Error");
         Console.WriteLine("2:Information");
         Console.WriteLine("3:Warning");
         Console.WriteLine("Select the Event Type");
         int myOption=Convert.ToInt32(Console.ReadLine());
         switch(myOption)
         {
            case 1:  myEventType="Error";
                     break;
            case 2:  myEventType="Information";
                     break;
            case 3:  myEventType="Warning";
                     break;
            default: break;
         }

            EventLogEntryCollection myLogEntryCollection=myEventLog.Entries;
            int myCount =myLogEntryCollection.Count;
            // Iterate through all 'EventLogEntry' instances in 'EventLog'.
            for(int i=myCount-1;i>-1;i--)
            {
               EventLogEntry myLogEntry = myLogEntryCollection[i];
               // Select the entry having desired EventType.
               if(myLogEntry.EntryType.ToString().Equals(myEventType))
               {
                  // Display Source of the event.
                  Console.WriteLine(myLogEntry.Source
                     +" was the source of last event of type "
                     +myLogEntry.EntryType);
                  return;
               }
            }
         }
   }
Imports System.Diagnostics

Class MyEventlogClass
   Public Shared Sub Main()
      Dim myEventType As String = Nothing
      ' Associate the instance of 'EventLog' with local System Log.
      Dim myEventLog As New EventLog("System", ".")
      Console.WriteLine("1:Error")
      Console.WriteLine("2:Information")
      Console.WriteLine("3:Warning")
      Console.WriteLine("Select the Event Type")
      Dim myOption As Integer = Convert.ToInt32(Console.ReadLine())
      Select Case myOption
         Case 1
            myEventType = "Error"
         Case 2
            myEventType = "Information"
         Case 3
            myEventType = "Warning"
         Case Else
      End Select

      Dim myLogEntryCollection As EventLogEntryCollection = myEventLog.Entries
      Dim myCount As Integer = myLogEntryCollection.Count
      ' Iterate through all 'EventLogEntry' instances in 'EventLog'.
      Dim i As Integer
      For i = myCount - 1 To 0 Step -1
         Dim myLogEntry As EventLogEntry = myLogEntryCollection(i)
         ' Select the entry having desired EventType.
         If myLogEntry.EntryType.ToString().Equals(myEventType) Then
            ' Display Source of the event.
            Console.WriteLine(myLogEntry.Source + " was the source of last "& _
                             "event of type " & myLogEntry.EntryType.ToString())
            Return
         End If
      Next 
   End Sub
End Class

설명

일반적으로 클래스를 사용할 때 직접 인스턴스를 EventLogEntryEventLog 만들지 않습니다. 클래스의 멤버에는 Entries 클래스 인덱스 멤버를 사용하여 읽을 때 반복하는 인스턴스 컬렉션 EventLogEntryEventLogEntryCollection.Item[] 포함 EventLog 됩니다.

Important

이 형식은 IDisposable 인터페이스를 구현합니다. 형식 사용을 마쳤으면 직접 또는 간접적으로 삭제해야 합니다. 형식을 직접 삭제하려면 Disposetry/ 블록에서 해당 catch 메서드를 호출합니다. 간접적으로 삭제하려면 using(C#) 또는 Using(Visual Basic)와 같은 언어 구문을 사용합니다. 자세한 내용은 인터페이스 항목의 "IDisposable을 구현하는 개체 사용" 섹션을 IDisposable 참조하세요.

속성

Name Description
CanRaiseEvents

구성 요소가 이벤트를 발생시키는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
Category

이 항목의 속성과 CategoryNumber 연결된 텍스트를 가져옵니다.

CategoryNumber

이벤트 로그 항목의 범주 번호를 가져옵니다.

Container

IContainer 포함하는 값을 가져옵니다 Component.

(다음에서 상속됨 Component)
Data

항목과 연결된 이진 데이터를 가져옵니다.

DesignMode

현재 디자인 모드인지 여부를 Component 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
EntryType

이 항목의 이벤트 유형을 가져옵니다.

EventID
사용되지 않음.

현재 이벤트 항목에 대한 애플리케이션별 이벤트 식별자를 가져옵니다.

Events

Component에 연결된 이벤트 처리기 목록을 가져옵니다.

(다음에서 상속됨 Component)
Index

이벤트 로그에서 이 항목의 인덱스입니다.

InstanceId

이벤트 항목의 메시지 텍스트를 지정하는 리소스 식별자를 가져옵니다.

MachineName

이 항목이 생성된 컴퓨터의 이름을 가져옵니다.

Message

이 이벤트 항목과 연결된 지역화된 메시지를 가져옵니다.

ReplacementStrings

이벤트 로그 항목과 연결된 대체 문자열을 가져옵니다.

Site

ISite를 가져오거나 Component의 값을 설정합니다.

(다음에서 상속됨 Component)
Source

이 이벤트를 생성한 애플리케이션의 이름을 가져옵니다.

TimeGenerated

이 이벤트가 생성된 현지 시간을 가져옵니다.

TimeWritten

이 이벤트가 로그에 기록된 현지 시간을 가져옵니다.

UserName

이 이벤트를 담당하는 사용자의 이름을 가져옵니다.

메서드

Name Description
CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시를 생성하는 데 필요한 모든 관련 정보를 포함하는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Dispose()

에서 사용하는 모든 리소스를 Component해제합니다.

(다음에서 상속됨 Component)
Dispose(Boolean)

관리되지 않는 리소스를 Component 해제하고 관리되는 리소스를 선택적으로 해제합니다.

(다음에서 상속됨 Component)
Equals(EventLogEntry)

두 이벤트 로그 항목 간의 비교를 수행합니다.

Equals(Object)

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

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

기본 해시 함수로 작동합니다.

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

이 인스턴스의 수명 정책을 제어하는 현재 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetService(Type)

또는 해당 서비스에서 제공하는 서비스를 나타내는 개체를 Component 반환합니다 Container.

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

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

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

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

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

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

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

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

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

String(있는 경우)의 Component이름을 포함하는 값을 반환합니다. 이 메서드는 재정의해서는 안 됩니다.

(다음에서 상속됨 Component)

이벤트

Name Description
Disposed

구성 요소가 메서드 호출에 Dispose() 의해 삭제될 때 발생합니다.

(다음에서 상속됨 Component)

명시적 인터페이스 구현

Name Description
ISerializable.GetObjectData(SerializationInfo, StreamingContext)

대상 개체를 SerializationInfo serialize하는 데 필요한 데이터로 채웁니다.

적용 대상

추가 정보