Esta documentación está archivada y no tiene mantenimiento.

EventLog.LogDisplayName (Propiedad)

Obtiene el nombre descriptivo del registro de eventos.

Espacio de nombres: System.Diagnostics
Ensamblado: System (en system.dll)

public string LogDisplayName { get; }
/** @property */
public String get_LogDisplayName ()

public function get LogDisplayName () : String

Valor de propiedad

Nombre que representa el registro de eventos en el visor de eventos del sistema.

Tipo de excepciónCondición

Exception

El registro no existe en el equipo especificado por la propiedad MachineName.

SystemException

La aplicación no ha podido abrir la clave del Registro asociada a este registro de eventos.

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 {
    // 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());

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

.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.

.NET Framework

Compatible con: 2.0, 1.1, 1.0
Mostrar: