Using C # Programming, view the system log, introduce two log classes: EventLog and EventLogEntry classes, and interact with the system log.
. NET Framework class library provides the EventLog class and the EventLogEntry class to interact with the system log. They belong to the System.Diagnostics namespace.
First declare a variable: Private Eventlogentrycollection eventcollection represents a collection of system logs.
The main properties of the EventLog class are:
Entris returns a Eventlogentrycollection value that represents the contents of the event log.
Log Gets or returns the name of the journal, where the application log is application, the system log is systems, and the security log is secure, and the default value is an empty string.
Logdisplayname gets the friendly name of the event log
MachineName Gets or sets the name of the computer on which the event is read or written
Source Gets or sets the names of the sources to register and use when writing to the event log
The Evententrycollection class defines the size and enumerator of the EventLogEntry instance collection.
Some of the main properties of the EventLogEntry class are as follows:
Category gets the text corresponding to the categorynumber of the item
Categorynumber Gets the category number of the item
Data gets the binary that corresponds to the item
EntryType Gets the event type for the item, whose value belongs to the EventLogEntryType enumeration, whose main members are as follows:
Error Error event, which indicates a serious problem that the user should know about, such as function or data loss
Failureaudit Failure Audit event. It indicates a security event that occurs when an audit access attempt fails, such as when an attempt to open a file fails
Information information events. It indicates important, successful events
Successaudit successful audit event. It indicates that auditing access attempts to succeed, such as security events that occur at successful logon
Warning Warning event. It indicates a problem that is not immediately important, but this problem may indicate a condition that will cause problems in the future.
EventID the application-specific event identifier for this event entry
Index gets the entry of the item in the event log
MachineName gets the name of the computer on which the item was generated
Message gets localized messages with this event
Replacementstrings get the replacement string for the item
Source gets the name of the application that generated the event
TimeGenerated gets the local time that generated the event
TimeWritten gets the local time when the log is written to the event
UserName gets the name of the user responsible for the event