EventLogEntryType EventLogEntryType EventLogEntryType EventLogEntryType Enum

定義

指定事件記錄檔項目的事件型別。Specifies the event type of an event log entry.

public enum class EventLogEntryType
public enum EventLogEntryType
type EventLogEntryType = 
Public Enum EventLogEntryType
繼承
EventLogEntryTypeEventLogEntryTypeEventLogEntryTypeEventLogEntryType

欄位

Error Error Error Error 1

錯誤事件。An error event. 這表示是使用者應該知道的重要問題,通常是功能或資料的遺失。This indicates a significant problem the user should know about; usually a loss of functionality or data.

FailureAudit FailureAudit FailureAudit FailureAudit 16

失敗稽核事件。A failure audit event. 這表示受稽核的存取嘗試失敗時發生的安全性事件,例如無法開啟檔案。This indicates a security event that occurs when an audited access attempt fails; for example, a failed attempt to open a file.

Information Information Information Information 4

資訊事件。An information event. 這表示重要成功的作業。This indicates a significant, successful operation.

SuccessAudit SuccessAudit SuccessAudit SuccessAudit 8

成功稽核事件。A success audit event. 這表示受稽核存取嘗試成功時所發生的安全性事件,例如登錄成功。This indicates a security event that occurs when an audited access attempt is successful; for example, logging on successfully.

Warning Warning Warning Warning 2

警告事件。A warning event. 這表示不是立即重要的問題,但是可能表示將來會引發問題的狀況。This indicates a problem that is not immediately significant, but that may signify conditions that could cause future problems.

範例

下列程式碼範例示範如何使用EventLogEntryType類別來新增相關的資訊觸發事件的記錄檔。The following code example demonstrates how to use the EventLogEntryType class to add information about triggered events to a log file. 在此範例中,switch陳述式用來判斷事件類型。In this example, a switch statement is used to determine the event type. 每個case陳述式會使用EventLogEntryType指定事件類型,會取得訊息和識別碼,並再將資訊寫入記錄檔。Each case statement uses the EventLogEntryType to specify the event type, gets the message and ID, and then writes the information to the log.

// Check whether source exist in event log.
if (  !EventLog::SourceExists( mySource ) )
{
   
   // Create a new source in a specified log on a system.
   EventLog::CreateEventSource( mySource, myLog );
}

// Create an event log instance.* myEventLog = new EventLog(myLog);
// Initialize source property of obtained instance.
myEventLog->Source = mySource;
switch ( myIntLog )
{
   case 1:
      
      // Write an 'Error' entry in specified log of event log.
      myEventLog->WriteEntry( myMessage, EventLogEntryType::Error, myID );
      break;

   case 2:
      
      // Write a 'Warning' entry in specified log of event log.
      myEventLog->WriteEntry( myMessage, EventLogEntryType::Warning, myID );
      break;

   case 3:
      
      // Write an 'Information' entry in specified log of event log.
      myEventLog->WriteEntry( myMessage, EventLogEntryType::Information, myID );
      break;

   case 4:
      
      // Write a 'FailureAudit' entry in specified log of event log.
      myEventLog->WriteEntry( myMessage, EventLogEntryType::FailureAudit, myID );
      break;

   case 5:
      
      // Write a 'SuccessAudit' entry in specified log of event log.
      myEventLog->WriteEntry( myMessage, EventLogEntryType::SuccessAudit, myID );
      break;

   default:
      Console::WriteLine( "Error: Failed to create an event in event log." );
      break;
}
Console::WriteLine( "A new event in log '{0}' with ID '{1}' is successfully written into event log.", myEventLog->Log, myID );


// Create an event log instance.
myEventLog = new EventLog(myLog);
// Initialize source property of obtained instance.
myEventLog.Source = mySource;
switch (myIntLog)
{
    case 1:
        // Write an 'Error' entry in specified log of event log.
        myEventLog.WriteEntry(myMessage, EventLogEntryType.Error, myID);
        break;
    case 2:
        // Write a 'Warning' entry in specified log of event log.
        myEventLog.WriteEntry(myMessage, EventLogEntryType.Warning, myID);
        break;
    case 3:
        // Write an 'Information' entry in specified log of event log.
        myEventLog.WriteEntry(myMessage, EventLogEntryType.Information, myID);
        break;
    case 4:
        // Write a 'FailureAudit' entry in specified log of event log.
        myEventLog.WriteEntry(myMessage, EventLogEntryType.FailureAudit, myID);
        break;
    case 5:
        // Write a 'SuccessAudit' entry in specified log of event log.
        myEventLog.WriteEntry(myMessage, EventLogEntryType.SuccessAudit, myID);
        break;
    default:
        Console.WriteLine("Error: Failed to create an event in event log.");
        break;
}
Console.WriteLine("A new event in log '{0}' with ID '{1}' "
   + "is successfully written into event log.",
   myEventLog.Log, myID);
' Check whether source exist in event log.
If False = EventLog.SourceExists(mySource) Then
   ' Create a new source in a specified log on a system.
   EventLog.CreateEventSource(mySource, myLog)
End If
' Create an event log instance.
myEventLog = New EventLog(myLog)
' Initialize source property of obtained instance.
myEventLog.Source = mySource
Select Case myIntLog
   Case 1
      ' Write an 'Error' entry in specified log of event log.
      myEventLog.WriteEntry(myMessage, EventLogEntryType.Error, myID)
   Case 2
      ' Write a 'Warning' entry in specified log of event log.
      myEventLog.WriteEntry(myMessage, EventLogEntryType.Warning, myID)
   Case 3
      ' Write an 'Information' entry in specified log of event log.
      myEventLog.WriteEntry(myMessage, EventLogEntryType.Information, myID)
   Case 4
      ' Write a 'FailureAudit' entry in specified log of event log.
      myEventLog.WriteEntry(myMessage, EventLogEntryType.FailureAudit, myID)
   Case 5
      ' Write a 'SuccessAudit' entry in specified log of event log.
      myEventLog.WriteEntry(myMessage, EventLogEntryType.SuccessAudit, myID)
   Case Else
      Console.WriteLine("Error: Failed to create an event in event log.")
End Select
Console.WriteLine("A new event in log '{0}' with ID '{1}' " + _
         "is successfully written into event log.", myEventLog.Log, myID)

備註

事件記錄檔項目的型別提供項目的其他資訊。The type of an event log entry provides additional information for the entry. 當這些項目寫入事件記錄檔時,應用程式設定的項目類型。Applications set the entry type when they write the entry to the event log.

每個事件必須是類型的單一;事件類型不能合併的項目。Each event must be of a single type; the event types cannot be combined for an entry. 事件檢視器會使用這個型別判斷要在記錄檔的清單檢視中顯示哪個圖示。The Event Viewer uses this type to determine which icon to display in the list view of the log.

適用於

另請參閱