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使用来指定事件类型、获取消息和 ID, 然后将该信息写入日志。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.

适用于

另请参阅