Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Propiedad EventLog::Entries

 

Publicado: octubre de 2016

Obtiene el contenido del registro de eventos.

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

public:
[BrowsableAttribute(false)]
property EventLogEntryCollection^ Entries {
	EventLogEntryCollection^ get();
}

Valor de propiedad

Type: System.Diagnostics::EventLogEntryCollection^

EventLogEntryCollection que incluye las entradas del registro de eventos. Cada entrada se asocia a una instancia de la clase EventLogEntry.

Use the P:System.Diagnostics.EventLog.Entries member when reading from the event log.

Because the property is read-only, you cannot modify an entry or write to the log using P:System.Diagnostics.EventLog.Entries. Instead, specify a P:System.Diagnostics.EventLog.Source and call Overload:System.Diagnostics.EventLog.WriteEntry to write a new log entry. You can use P:System.Diagnostics.EventLog.Entries to count the number of entries in the event log, and view each T:System.Diagnostics.EventLogEntry in the collection. Use the indexed P:System.Diagnostics.EventLogEntryCollection.Item(System.Int32) member to retrieve information about a specific entry, such as P:System.Diagnostics.EventLogEntry.Message, P:System.Diagnostics.EventLogEntry.Category, P:System.Diagnostics.EventLogEntry.TimeWritten, or P:System.Diagnostics.EventLogEntry.EntryType.

It is not necessary to specify a P:System.Diagnostics.EventLog.Source when only reading from a log. You can specify only the P:System.Diagnostics.EventLog.Log name and P:System.Diagnostics.EventLog.MachineName (server computer name) properties for the T:System.Diagnostics.EventLog instance. In either case, the P:System.Diagnostics.EventLog.Entries member is automatically populated with the event log's list of entries. You can select the appropriate index for an item in this list to read individual entries.

An important distinction between reading and writing log entries is that it is not necessary to explicitly call a read method. After the P:System.Diagnostics.EventLog.Log and P:System.Diagnostics.EventLog.MachineName are specified, the P:System.Diagnostics.EventLog.Entries property is automatically populated. If you change the value of the P:System.Diagnostics.EventLog.Log or P:System.Diagnostics.EventLog.MachineName property, the P:System.Diagnostics.EventLog.Entries property is repopulated the next time you read it.

System_CAPS_noteNota

You are not required to specify the P:System.Diagnostics.EventLog.MachineName if you are connecting to a log. If you do not specify the P:System.Diagnostics.EventLog.MachineName, the local computer, ".", is assumed.

The following example reads entries in the event log, "MyNewLog", on the local computer.

#using <System.dll>

using namespace System;
using namespace System::Diagnostics;
int main()
{
   EventLog^ myLog = gcnew EventLog;
   myLog->Log = "MyNewLog";
   System::Collections::IEnumerator^ myEnum = myLog->Entries->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      EventLogEntry^ entry = safe_cast<EventLogEntry^>(myEnum->Current);
      Console::WriteLine( "\tEntry: {0}", entry->Message );
   }
}

EventLogPermission

for administering event log information on the computer. Associated enumeration: F:System.Diagnostics.EventLogPermissionAccess.Administer

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: