Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft den Ereignistyp dieses Eintrags ab.
Namespace: System.Diagnostics
Assembly: System (in system.dll)
Syntax
'Declaration
Public ReadOnly Property EntryType As EventLogEntryType
'Usage
Dim instance As EventLogEntry
Dim value As EventLogEntryType
value = instance.EntryType
public EventLogEntryType EntryType { get; }
public:
property EventLogEntryType EntryType {
EventLogEntryType get ();
}
/** @property */
public EventLogEntryType get_EntryType ()
public function get EntryType () : EventLogEntryType
Eigenschaftenwert
Der EventLogEntryType, der den Ereignistyp angibt, der dem Eintrag im Ereignisprotokoll zugeordnet ist.
Hinweise
Alle Ereignistypen verfügen über stringente allgemeine Daten und können optional auch ereignisspezifische Daten umfassen. Jedes Ereignis ist von einem Typ, der von der Anwendung beim Melden des Ereignisses angegeben wird. Mithilfe des Ereignistyps wird von der Ereignisanzeige bestimmt, welches Symbol in der Listenansicht des Ereignisprotokolls angezeigt werden soll.
Beispiel
Imports System
Imports System.Diagnostics
Class MyEventlogClass
Public Shared Sub Main()
Dim myEventType As String = Nothing
' Associate the instance of 'EventLog' with local System Log.
Dim myEventLog As New EventLog("System", ".")
Console.WriteLine("1:Error")
Console.WriteLine("2:Information")
Console.WriteLine("3:Warning")
Console.WriteLine("Select the Event Type")
Dim myOption As Integer = Convert.ToInt32(Console.ReadLine())
Select Case myOption
Case 1
myEventType = "Error"
Case 2
myEventType = "Information"
Case 3
myEventType = "Warning"
Case Else
End Select
Dim myLogEntryCollection As EventLogEntryCollection = myEventLog.Entries
Dim myCount As Integer = myLogEntryCollection.Count
' Iterate through all 'EventLogEntry' instances in 'EventLog'.
Dim i As Integer
For i = myCount - 1 To -1 Step -1
Dim myLogEntry As EventLogEntry = myLogEntryCollection(i)
' Select the entry having desired EventType.
If myLogEntry.EntryType.ToString().Equals(myEventType) Then
' Display Source of the event.
Console.WriteLine(myLogEntry.Source + " was the source of last "& _
"event of type " & myLogEntry.EntryType.ToString())
Return
End If
Next i
End Sub 'Main
End Class 'MyEventlogClass
using System;
using System.Diagnostics;
class MyEventlogClass
{
public static void Main()
{
String myEventType=null;
// Associate the instance of 'EventLog' with local System Log.
EventLog myEventLog = new EventLog("System", ".");
Console.WriteLine("1:Error");
Console.WriteLine("2:Information");
Console.WriteLine("3:Warning");
Console.WriteLine("Select the Event Type");
int myOption=Convert.ToInt32(Console.ReadLine());
switch(myOption)
{
case 1: myEventType="Error";
break;
case 2: myEventType="Information";
break;
case 3: myEventType="Warning";
break;
default: break;
}
EventLogEntryCollection myLogEntryCollection=myEventLog.Entries;
int myCount =myLogEntryCollection.Count;
// Iterate through all 'EventLogEntry' instances in 'EventLog'.
for(int i=myCount-1;i>0;i--)
{
EventLogEntry myLogEntry = myLogEntryCollection[i];
// Select the entry having desired EventType.
if(myLogEntry.EntryType.ToString().Equals(myEventType))
{
// Display Source of the event.
Console.WriteLine(myLogEntry.Source
+" was the source of last event of type "
+myLogEntry.EntryType);
return;
}
}
}
}
#using <System.dll>
using namespace System;
using namespace System::Diagnostics;
int main()
{
String^ myEventType = nullptr;
// Associate the instance of 'EventLog' with local System Log.
EventLog^ myEventLog = gcnew EventLog( "System","." );
Console::WriteLine( "1:Error" );
Console::WriteLine( "2:Information" );
Console::WriteLine( "3:Warning" );
Console::WriteLine( "Select the Event Type" );
int myOption = Convert::ToInt32( Console::ReadLine() );
switch ( myOption )
{
case 1:
myEventType = "Error";
break;
case 2:
myEventType = "Information";
break;
case 3:
myEventType = "Warning";
break;
default:
break;
}
EventLogEntryCollection^ myLogEntryCollection = myEventLog->Entries;
int myCount = myLogEntryCollection->Count;
// Iterate through all 'EventLogEntry' instances in 'EventLog'.
for ( int i = myCount - 1; i > 0; i-- )
{
EventLogEntry^ myLogEntry = myLogEntryCollection[ i ];
// Select the entry having desired EventType.
if ( myLogEntry->EntryType.Equals( myEventType ) )
{
// Display Source of the event.
Console::WriteLine( "{0} was the source of last event of type {1}", myLogEntry->Source, myLogEntry->EntryType );
return 0;
}
}
}
import System.*;
import System.Diagnostics.*;
class MyEventlogClass
{
public static void main(String[] args)
{
String myEventType = null;
// Associate the instance of 'EventLog' with local System Log.
EventLog myEventLog = new EventLog("System", ".");
Console.WriteLine("1:Error");
Console.WriteLine("2:Information");
Console.WriteLine("3:Warning");
Console.WriteLine("Select the Event Type");
int myOption = Convert.ToInt32(Console.ReadLine());
switch (myOption) {
case 1:
myEventType = "Error";
break;
case 2:
myEventType = "Information";
break;
case 3:
myEventType = "Warning";
break;
default:
break;
}
EventLogEntryCollection myLogEntryCollection = myEventLog.get_Entries();
int myCount = myLogEntryCollection.get_Count();
// Iterate through all 'EventLogEntry' instances in 'EventLog'.
for (int i = myCount - 1; i > 0; i--) {
EventLogEntry myLogEntry = myLogEntryCollection.get_Item(i);
// Select the entry having desired EventType.
if (myLogEntry.get_EntryType().ToString().Equals(myEventType)) {
// Display Source of the event.
Console.WriteLine(myLogEntry.get_Source()
+ " was the source of last event of type "
+ myLogEntry.get_EntryType());
return;
}
}
} //main
} //MyEventlogClass
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
EventLogEntry-Klasse
EventLogEntry-Member
System.Diagnostics-Namespace
EventLogEntryType
EventInstance.EntryType-Eigenschaft