EventLogEntryType 列舉

定義

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

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

欄位

Error 1

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

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 4

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

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 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.

適用於

另請參閱