EventLogEntryType Enum
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Specifies the event type of an event log entry.
public enum class EventLogEntryType
public enum EventLogEntryType
type EventLogEntryType =
Public Enum EventLogEntryType
- Inheritance
Fields
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. |
Examples
The following code example demonstrates how to use the EventLogEntryType class to add information about triggered events to a log file. In this example, a switch
statement is used to determine the event type. 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)
Remarks
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.
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기