Export (0) Print
Expand All
Expand Minimize

EventLogEntryType Enumeration

Specifies the event type of an event log entry.

[Visual Basic]
<Serializable>
Public Enum EventLogEntryType
[C#]
[Serializable]
public enum EventLogEntryType
[C++]
[Serializable]
__value public enum EventLogEntryType
[JScript]
public
   Serializable
enum EventLogEntryType

Remarks

The type of an event log entry is used to indicate the severity of an event log entry.

Each event must be of a single type, which the application indicates when it reports the event. The Event Viewer uses this type to determine which icon to display in the list view of the log.

Members

Member name Description
Error An error event. This indicates a significant problem the user should know about; usually a loss of functionality or data.
FailureAudit 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 An information event. This indicates a significant, successful operation.
SuccessAudit A success audit event. This indicates a security event that occurs when an audited access attempt is successful; for example, logging on successfully.
Warning A warning event. This indicates a problem that is not immediately significant, but that may signify conditions that could cause future problems.

Example

[Visual Basic] 
' 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)

[C#] 
// 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 );

[C++] 
// 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(S"Error: Failed to create an event in event log.");
    break;
}
Console::WriteLine(S"A new event in log '{0}' with ID '{1}' is successfully written into event log.",
    myEventLog->Log, __box(myID));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Diagnostics

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

System.Diagnostics Namespace | EventLogEntry

Show:
© 2014 Microsoft