EventLogEntryType 枚举

指定事件日志项的事件类型。

**命名空间:**System.Diagnostics
**程序集:**System(在 system.dll 中)

语法

声明
Public Enumeration EventLogEntryType
用法
Dim instance As EventLogEntryType
public enum EventLogEntryType
public enum class EventLogEntryType
public enum EventLogEntryType
public enum EventLogEntryType

成员

  成员名称 说明
Error 错误事件。它指示用户应该知道的严重问题(通常是功能或数据的丢失)。 
FailureAudit 失败审核事件。它指示当审核访问尝试失败(例如打开文件的尝试失败)时发生的安全事件。 
Information 信息事件。它指示重要、成功的操作。 
SuccessAudit 成功审核事件。它指示当审核访问尝试成功(例如成功登录)时发生的安全事件。 
Warning 警告事件。它指示并不立即具有重要性的问题,但此问题可能表示将来会导致问题的条件。 

备注

事件日志项的类型可为该项提供附加信息。应用程序在事件日志中写入一个日志项时会设置该项的类型。

每个事件必须具有单一的类型;不能在一个日志项中组合多个事件类型。事件查看器使用该类型来确定在日志的列表视图中显示哪一个图标。

示例

' 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)
// Check whether source exist in event log.
if( false == 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 );
// 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 );
// Check whether source exist in event log.
if (false == 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.set_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.get_Log(),(Int32) myID);

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

System.Diagnostics 命名空间
EventLogEntry 类