EventSourceCreationData.LogName Propiedad

Definición

Obtiene o establece el nombre del registro de eventos en el que el origen escribe las entradas.

public:
 property System::String ^ LogName { System::String ^ get(); void set(System::String ^ value); };
public string LogName { get; set; }
member this.LogName : string with get, set
Public Property LogName As String

Valor de propiedad

Nombre del registro de eventos. Puede ser Application, System o el nombre de un registro personalizado. El valor predeterminado es "Application".

Ejemplos

En el ejemplo de código siguiente se establecen las propiedades de configuración de un origen de eventos a partir de argumentos de línea de comandos. Los argumentos de entrada especifican el nombre del origen del evento, el nombre del registro de eventos, el nombre del equipo y el archivo de recursos del mensaje de evento. Este ejemplo forma parte de un ejemplo más grande proporcionado para la EventSourceCreationData clase .

EventSourceCreationData ^ mySourceData = gcnew EventSourceCreationData( "","" );
bool registerSource = true;

// Process input parameters.
if ( args->Length > 1 )
{
   
   // Require at least the source name.
   mySourceData->Source = args[ 1 ];
   if ( args->Length > 2 )
   {
      mySourceData->LogName = args[ 2 ];
   }

   if ( args->Length > 3 )
   {
      mySourceData->MachineName = args[ 3 ];
   }

   if ( (args->Length > 4) && (args[ 4 ]->Length > 0) )
   {
      mySourceData->MessageResourceFile = args[ 4 ];
   }
}
else
{
   
   // Display a syntax help message.
   Console::WriteLine( "Input:" );
   Console::WriteLine( " source [event log] [machine name] [resource file]" );
   registerSource = false;
}


// Set defaults for parameters missing input.
if ( mySourceData->MachineName->Length == 0 )
{
   
   // Default to the local computer.
   mySourceData->MachineName = ".";
}

if ( mySourceData->LogName->Length == 0 )
{
   
   // Default to the Application log.
   mySourceData->LogName = "Application";
}
EventSourceCreationData mySourceData = new EventSourceCreationData("", "");
bool registerSource = true;

// Process input parameters.
if (args.Length > 0)
{
    // Require at least the source name.

    mySourceData.Source = args[0];

    if (args.Length > 1)
    {
        mySourceData.LogName = args[1];
    }

    if (args.Length > 2)
    {
        mySourceData.MachineName = args[2];
    }
    if ((args.Length > 3) && (args[3].Length > 0))
    {
        mySourceData.MessageResourceFile = args[3];
    }
}
else
{
    // Display a syntax help message.
    Console.WriteLine("Input:");
    Console.WriteLine(" source [event log] [machine name] [resource file]");

    registerSource = false;
}

// Set defaults for parameters missing input.
if (mySourceData.MachineName.Length == 0)
{
    // Default to the local computer.
    mySourceData.MachineName = ".";
}
if (mySourceData.LogName.Length == 0)
{
    // Default to the Application log.
    mySourceData.LogName = "Application";
}
         Dim mySourceData As EventSourceCreationData = new EventSourceCreationData("", "")
         Dim registerSource As Boolean = True

         ' Process input parameters.
         If args.Length > 0
             ' Require at least the source name.

             mySourceData.Source = args(0)

             If args.Length > 1

                 mySourceData.LogName = args(1)
 
             End If
             If args.Length > 2

                 mySourceData.MachineName = args(2)
 
             End If
             If args.Length > 3 AndAlso args(3).Length > 0

                 mySourceData.MessageResourceFile = args(3)
 
             End If

         Else 
             ' Display a syntax help message.
             Console.WriteLine("Input:")
             Console.WriteLine(" source [event log] [machine name] [resource file]")

             registerSource = False
         End If

         ' Set defaults for parameters missing input.
         If mySourceData.MachineName.Length = 0
         
             ' Default to the local computer.
             mySourceData.MachineName = "."
         End If
         If mySourceData.LogName.Length = 0
             ' Default to the Application log.
             mySourceData.LogName = "Application"
         End If

Comentarios

Use la LogName propiedad para identificar el registro de eventos en el que la aplicación escribe entradas en mediante el nuevo origen. El registro de eventos puede ser un registro nuevo o un registro existente. Las aplicaciones y los servicios deben escribir en el registro de aplicaciones o en un registro personalizado. Los controladores de dispositivo deben escribir en el registro del sistema. Si no establece explícitamente la LogName propiedad , el registro de eventos tiene como valor predeterminado el registro de aplicaciones.

Nota

El registro de seguridad es de solo lectura.

Para establecer como destino un registro existente para el nuevo origen, establezca la LogName propiedad en el nombre del registro de eventos existente. Para crear un nuevo registro de eventos para el origen, debe establecer la LogName propiedad . Los nombres del registro de eventos deben constar de caracteres imprimibles y no pueden incluir los caracteres '*', '?' o '\'. Los primeros 8 caracteres del nombre del registro de eventos deben ser diferentes de los primeros 8 caracteres de los nombres existentes de los registros de eventos en el equipo especificado.

El sistema operativo almacena los registros de eventos como archivos. Cuando se usa EventLogInstaller o el CreateEventSource método para crear un nuevo registro de eventos, el archivo asociado se almacena en el directorio %SystemRoot%\System32\Config en el equipo especificado. El nombre de archivo se establece anexando los primeros 8 caracteres de la LogName propiedad con la extensión de nombre de archivo ".evt".

Se aplica a

Consulte también