EventInstance 클래스

정의

이벤트 로그 엔트리에 대한 언어 중립 정보를 나타냅니다.

public ref class EventInstance
public class EventInstance
type EventInstance = class
Public Class EventInstance
상속
EventInstance

예제

다음 코드 예제에서는 정보 이벤트 항목을 작성한 다음 를 다시 사용하여 EventInstance 경고 이벤트에 대한 항목을 기존 이벤트 로그에 씁니다. 이벤트 메시지 텍스트는 메시지 리소스 파일의 리소스 식별자를 사용하여 지정됩니다. 코드 예제에서는 해당 메시지 리소스 파일이 원본에 대해 등록되었다고 가정합니다.

// Ensure that the source has already been registered using
// EventLogInstaller or EventLog.CreateEventSource.
String^ sourceName = "SampleApplicationSource";
if ( EventLog::SourceExists( sourceName ) )
{
   // Define an informational event with no category.
   // The message identifier corresponds to the message text in the
   // message resource file defined for the source.
   EventInstance ^ myEvent = gcnew EventInstance( UpdateCycleCompleteMsgId,0 );

   // Write the event to the event log using the registered source.
   EventLog::WriteEvent( sourceName, myEvent, 0 );

   // Reuse the event data instance for another event entry.
   // Set the entry category and message identifiers for
   // the appropriate resource identifiers in the resource files
   // for the registered source.  Set the event type to Warning.
   myEvent->CategoryId = RefreshCategoryMsgId;
   myEvent->EntryType = EventLogEntryType::Warning;
   myEvent->InstanceId = ServerConnectionDownMsgId;

   // Write the event to the event log using the registered source.
   // Insert the machine name into the event message text.
   array<String^>^ss = {Environment::MachineName};
   EventLog::WriteEvent( sourceName, myEvent, ss );
}
else
{
   Console::WriteLine( "Warning - event source {0} not registered", sourceName );
}

// Ensure that the source has already been registered using
// EventLogInstaller or EventLog.CreateEventSource.

string sourceName = "SampleApplicationSource";
if(EventLog.SourceExists(sourceName))
{
    // Define an informational event with no category.
    // The message identifier corresponds to the message text in the
    // message resource file defined for the source.
    EventInstance myEvent = new EventInstance(UpdateCycleCompleteMsgId, 0);

    // Write the event to the event log using the registered source.
    EventLog.WriteEvent(sourceName, myEvent);

    // Reuse the event data instance for another event entry.
    // Set the entry category and message identifiers for
    // the appropriate resource identifiers in the resource files
    // for the registered source.  Set the event type to Warning.

    myEvent.CategoryId = RefreshCategoryMsgId;
    myEvent.EntryType = EventLogEntryType.Warning;
    myEvent.InstanceId = ServerConnectionDownMsgId;

    // Write the event to the event log using the registered source.
    // Insert the machine name into the event message text.
    EventLog.WriteEvent(sourceName, myEvent, Environment.MachineName);
}
else
{
    Console.WriteLine("Warning - event source {0} not registered",
        sourceName);
}
' Ensure that the source has already been registered using
' EventLogInstaller or EventLog.CreateEventSource.
Dim sourceName as String = "SampleApplicationSource"
If EventLog.SourceExists(sourceName)
    
    ' Define an informational event with no category.
    ' The message identifier corresponds to the message text in the
    ' message resource file defined for the source.
    Dim myEvent As EventInstance = New EventInstance(UpdateCycleCompleteMsgId, 0)
    ' Write the event to the event log using the registered source.
    EventLog.WriteEvent(sourceName, myEvent)

    ' Reuse the event data instance for another event entry.
    ' Set the entry category and message identifiers for
    ' the appropriate resource identifiers in the resource files
    ' for the registered source.  Set the event type to Warning.

    myEvent.CategoryId = RefreshCategoryMsgId
    myEvent.EntryType = EventLogEntryType.Warning
    myEvent.InstanceId = ServerConnectionDownMsgId

    ' Write the event to the event log using the registered source.
    ' Insert the machine name into the event message text.
    EventLog.WriteEvent(sourceName, myEvent, Environment.MachineName)

Else 
    Console.WriteLine("Warning - event source {0} not registered", _
        sourceName)
End If

코드 예제에서는 리소스 라이브러리 EventLogMsgs.dll 내장 다음 메시지 텍스트 파일을 사용 합니다. 메시지 텍스트 파일은 메시지 리소스 파일 생성 되는 원본. 메시지 텍스트 파일의 리소스 식별자와 범주, 이벤트 메시지 및 매개 변수 삽입 문자열에 대 한 텍스트를 정의합니다.

; // EventLogMsgs.mc  
; // ********************************************************  

; // Use the following commands to build this file:  

; //   mc -s EventLogMsgs.mc  
; //   rc EventLogMsgs.rc  
; //   link /DLL /SUBSYSTEM:WINDOWS /NOENTRY /MACHINE:x86 EventLogMsgs.Res   
; // ********************************************************  

; // - Event categories -  
; // Categories must be numbered consecutively starting at 1.  
; // ********************************************************  

MessageId=0x1  
Severity=Success  
SymbolicName=INSTALL_CATEGORY  
Language=English  
Installation  
.  

MessageId=0x2  
Severity=Success  
SymbolicName=QUERY_CATEGORY  
Language=English  
Database Query  
.  

MessageId=0x3  
Severity=Success  
SymbolicName=REFRESH_CATEGORY  
Language=English  
Data Refresh  
.  

; // - Event messages -  
; // *********************************  

MessageId = 1000  
Severity = Success  
Facility = Application  
SymbolicName = AUDIT_SUCCESS_MESSAGE_ID_1000  
Language=English  
My application message text, in English, for message id 1000, called from %1.  
.  

MessageId = 1001  
Severity = Warning  
Facility = Application  
SymbolicName = AUDIT_FAILED_MESSAGE_ID_1001  
Language=English  
My application message text, in English, for message id 1001, called from %1.  
.  

MessageId = 1002  
Severity = Success  
Facility = Application  
SymbolicName = GENERIC_INFO_MESSAGE_ID_1002  
Language=English  
My generic information message in English, for message id 1002.  
.  

MessageId = 1003  
Severity = Warning  
Facility = Application  
SymbolicName = GENERIC_WARNING_MESSAGE_ID_1003  
Language=English  
My generic warning message in English, for message id 1003, called from %1.  
.  

MessageId = 1004  
Severity = Success  
Facility = Application  
SymbolicName = UPDATE_CYCLE_COMPLETE_MESSAGE_ID_1004  
Language=English  
The update cycle is complete for %%5002.  
.  

MessageId = 1005  
Severity = Warning  
Facility = Application  
SymbolicName = SERVER_CONNECTION_DOWN_MESSAGE_ID_1005  
Language=English  
The refresh operation did not complete because the connection to server %1 could not be established.  
.  

; // - Event log display name -  
; // ********************************************************  

MessageId = 5001  
Severity = Success  
Facility = Application  
SymbolicName = EVENT_LOG_DISPLAY_NAME_MSGID  
Language=English  
Sample Event Log  
.  

; // - Event message parameters -  
; //   Language independent insertion strings  
; // ********************************************************  

MessageId = 5002  
Severity = Success  
Facility = Application  
SymbolicName = EVENT_LOG_SERVICE_NAME_MSGID  
Language=English  
SVC_UPDATE.EXE  
.  

설명

를 사용하여 EventInstance 문자열 값이 아닌 리소스 식별자를 사용하여 이벤트 로그 항목을 작성합니다. 이벤트 로그 항목을 작성하려면 속성을 초기화 InstanceId 하고 메서드에 instance WriteEvent 전달합니다. 이벤트 뷰어 instance 식별자를 사용하여 현재 언어 설정에 따라 지역화된 리소스 파일에서 해당 문자열을 찾아 표시합니다. 리소스 식별자를 사용하여 이벤트를 작성하기 전에 해당 리소스 파일에 이벤트 원본을 등록해야 합니다.

이벤트를 작성할 때 속성을 설정 EntryType 하여 항목에 대해 이벤트 뷰어 표시하는 아이콘을 지정할 수 있습니다. 속성을 지정 CategoryId 하여 항목에 대해 이벤트 뷰어 표시하는 범주를 지정할 수도 있습니다.

이벤트 뷰어 범주를 사용하여 이벤트 원본에서 작성한 이벤트를 필터링합니다. 이벤트 뷰어 범주를 숫자 값으로 표시하거나 범주를 리소스 식별자로 사용하여 지역화된 범주 문자열을 표시할 수 있습니다.

이벤트 뷰어 지역화된 범주 문자열을 표시하려면 범주 리소스 파일로 구성된 이벤트 원본을 사용하고 를 범주 리소스 파일의 리소스 식별자로 설정 CategoryId 해야 합니다. 이벤트 원본에 구성된 범주 리소스 파일이 없거나 지정된 CategoryId 가 범주 리소스 파일에서 문자열을 인덱싱하지 않는 경우 이벤트 뷰어 해당 항목의 숫자 범주 값을 표시합니다. 또는 클래스를 사용하여 EventLogInstaller 리소스 파일의 범주 문자열 수와 함께 범주 리소스 파일을 구성합니다 EventSourceCreationData .

를 사용하여 메서드를 사용하여 EventInstance 이벤트를 작성하기 전에 이벤트 로그에 대한 원본을 WriteEvent 등록해야 합니다. 로그에 지역화된 항목을 작성하도록 원본을 구성해야 하며 원본은 적어도 메시지 리소스 파일을 정의해야 합니다.

애플리케이션을 설치 하는 동안 새 이벤트 원본을 만듭니다. 이렇게 하면 등록 된 이벤트 소스 목록을 새로 고치고 해당 구성에 운영 체제 있습니다. 운영 체제에서 이벤트 소스 목록을 새로 고치지 않은 경우 쓰려고 하면 새 원본 사용 하는 이벤트는 쓰기 작업이 실패 합니다. 사용 하 여 새 소스를 구성할 수 있습니다는 EventLogInstaller를 사용 하 여 또는 CreateEventSource 메서드. 새 이벤트 원본을 만들려면 컴퓨터에서 관리자 권한이 있어야 합니다.

이벤트 메시지를 정의하고 이벤트 로그 리소스 파일을 빌드하는 방법에 대한 자세한 내용은 플랫폼 SDK 설명서의 메시지 컴파일러 문서를 참조하세요.

생성자

EventInstance(Int64, Int32)

이벤트 엔트리의 지역화된 메시지 및 범주 텍스트에 대한 지정된 리소스 식별자를 사용하여 EventInstance 클래스의 새 인스턴스를 초기화합니다.

EventInstance(Int64, Int32, EventLogEntryType)

지역화된 메시지의 지정된 리소스 식별자, 이벤트 엔트리의 범주 텍스트 및 지정된 이벤트 로그 엔트리 형식을 사용하여 EventInstance 클래스의 새 인스턴스를 초기화합니다.

속성

CategoryId

애플리케이션에 정의된 이벤트 엔트리의 범주를 지정하는 리소스 식별자를 가져오거나 설정합니다.

EntryType

이벤트 로그 엔트리의 이벤트 형식을 가져오거나 설정합니다.

InstanceId

이벤트 엔트리의 메시지 텍스트를 지정하는 리소스 식별자를 가져오거나 설정합니다.

메서드

Equals(Object)

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

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

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

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

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

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

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

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

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보