Freigeben über


EventLog.LogDisplayName-Eigenschaft

Ruft den angezeigten Namen des Ereignisprotokolls ab.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

Syntax

'Declaration
Public ReadOnly Property LogDisplayName As String
'Usage
Dim instance As EventLog
Dim value As String

value = instance.LogDisplayName
public string LogDisplayName { get; }
public:
property String^ LogDisplayName {
    String^ get ();
}
/** @property */
public String get_LogDisplayName ()
public function get LogDisplayName () : String

Eigenschaftenwert

Ein Name, der das Ereignisprotokoll in der Ereignisanzeige des Systems darstellt.

Ausnahmen

Ausnahmetyp Bedingung

Exception

Das Protokoll ist auf dem durch die MachineName-Eigenschaft angegebenen Computer nicht vorhanden.

SystemException

Die Anwendung konnte den Registrierungsschlüssel, der diesem Ereignisprotokoll zugeordnet ist, nicht öffnen.

Beispiel

Dim myRemoteMachine As String
Dim myLogName as string = "MyLog"
Console.Write("Enter computer on which to create log : ")
myRemoteMachine = Console.ReadLine()

' Check if the source exists.
if not EventLog.SourceExists("MyTestSource") then
   'Create source.
   EventLog.CreateEventSource("MyTestSource", myLogName,myRemoteMachine)
   Console.WriteLine("Creating EventSource")
else
   'Get the EventLog associated if the source exists.
   myLogName = EventLog.LogNameFromSourceName("MyTestSource",myRemoteMachine)
end if

Dim myEventLog1 As New EventLog(myLogName, myRemoteMachine)
myEventLog1.Source = "MyTestSource"
' Write an entry into log.
myEventLog1.WriteEntry("This is for your information", _
                     EventLogEntryType.SuccessAudit, 100)
Console.WriteLine("An EventLog created on computer " + myEventLog1.MachineName)
Console.Write("Enter remote computer on which to create log : ")
myRemoteMachine = Console.ReadLine()

Dim myEventLog2 As New EventLog()
myEventLog2.MachineName = myRemoteMachine
myEventLog2.Source = "MyTestSource"
myEventLog2.Log = myEventLog1.LogDisplayName
myEventLog2.WriteEntry("This is for your information")
Console.WriteLine("An EventLog created on computer " + myEventLog2.MachineName)
string myRemoteMachine;
string myLogName = "MyLog";

Console.Write( "Enter computer on which to create log : " );
myRemoteMachine = Console.ReadLine();

// Check if the source exists.
if(!EventLog.SourceExists("MyTestSource"))
{
   //Create source.
   EventLog.CreateEventSource("MyTestSource", myLogName,myRemoteMachine);
   Console.WriteLine("Creating EventSource");
}
else
   // Get the EventLog associated if the source exists.
   myLogName = EventLog.LogNameFromSourceName("MyTestSource",myRemoteMachine);

EventLog myEventLog1 = new EventLog(myLogName,myRemoteMachine);
myEventLog1.Source = "MyTestSource";
// Write an entry into log.
myEventLog1.WriteEntry("This is for your information",
                               EventLogEntryType.SuccessAudit,100);
Console.WriteLine("An EventLog created on computer "+ 
                               myEventLog1.MachineName);

Console.Write( "Enter remote computer on which to create log : " );
myRemoteMachine = Console.ReadLine();

EventLog myEventLog2 = new EventLog();
myEventLog2.MachineName = myRemoteMachine;
myEventLog2.Source = "MyTestSource";
myEventLog2.Log = myEventLog1.LogDisplayName;
myEventLog2.WriteEntry("This is for your information");
Console.WriteLine("An EventLog created on computer "+ 
                                   myEventLog2.MachineName);
String^ myRemoteMachine;
String^ myLogName = "MyLog";

Console::Write( "Enter computer on which to create log : " );
myRemoteMachine = Console::ReadLine();

// Check if the source exists.
if (  !EventLog::SourceExists( "MyTestSource" ) )
{
   //Create source.
   EventLog::CreateEventSource( "MyTestSource", myLogName, myRemoteMachine );
   Console::WriteLine( "Creating EventSource" );
}
else
      myLogName = EventLog::LogNameFromSourceName( "MyTestSource", myRemoteMachine );

// Get the EventLog associated if the source exists.
EventLog^ myEventLog1 = gcnew EventLog( myLogName,myRemoteMachine );
myEventLog1->Source = "MyTestSource";

// Write an entry into log.
myEventLog1->WriteEntry( "This is for your information",
   EventLogEntryType::SuccessAudit, 100 );
Console::WriteLine( "An EventLog created on computer {0}",
   myEventLog1->MachineName );

Console::Write( "Enter remote computer on which to create log : " );
myRemoteMachine = Console::ReadLine();

EventLog^ myEventLog2 = gcnew EventLog;
myEventLog2->MachineName = myRemoteMachine;
myEventLog2->Source = "MyTestSource";
myEventLog2->Log = myEventLog1->LogDisplayName;
myEventLog2->WriteEntry( "This is for your information" );
Console::WriteLine( "An EventLog created on computer {0}",
   myEventLog2->MachineName );
String myRemoteMachine;
String myLogName = "MyLog";

Console.Write("Enter computer on which to create log : ");
myRemoteMachine = Console.ReadLine();

// Check if the source exists.
if (!(EventLog.SourceExists("MyTestSource"))) {
    //Create source.
    EventLog.CreateEventSource("MyTestSource",
        myLogName, myRemoteMachine);
    Console.WriteLine("Creating EventSource");
}                
else {
    // Get the EventLog associated if the source exists.
    myLogName = EventLog.LogNameFromSourceName("MyTestSource",
        myRemoteMachine);
}

EventLog myEventLog1 = new EventLog(myLogName, myRemoteMachine);

myEventLog1.set_Source("MyTestSource");

// Write an entry into log.
myEventLog1.WriteEntry("This is for your information",
    EventLogEntryType.SuccessAudit, 100);
Console.WriteLine("An EventLog created on computer " 
    + myEventLog1.get_MachineName());
Console.Write("Enter remote computer on which to create log : ");
myRemoteMachine = Console.ReadLine();
EventLog myEventLog2 = new EventLog();
myEventLog2.set_MachineName(myRemoteMachine);
myEventLog2.set_Source("MyTestSource");
myEventLog2.set_Log(myEventLog1.get_LogDisplayName());
myEventLog2.WriteEntry("This is for your information");
Console.WriteLine("An EventLog created on computer " 
    + myEventLog2.get_MachineName());

.NET Framework-Sicherheit

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

EventLog-Klasse
EventLog-Member
System.Diagnostics-Namespace
RegisterDisplayName