Commands relating to reading and writing the Windows event log
This module provides commands for reading and writing the Windows event log.
Most access to the event log requires a handle returned by the eventlog_open command. A handle allows either read or write access, but never both. Events can be written using the eventlog_write command. The eventlog_log command provides an alternate, simpler but less flexible, interface for writing events. Events can be read from an event log through the eventlog_read command. The returned event record can be formatted using eventlog_format_message and eventlog_format_category.
The command eventlog_count returns the number of records in the event log. eventlog_oldest returns the record number of the oldest record. The command eventlog_is_full indicates whether the event log is full.
To monitor the event log in real time, an application can poll at regular intervals. However, a more efficient way is to receive asynchronous notifications through eventlog_monitor_start when new events are logged. These notifications can be turned off using eventlog_monitor_stop.
Event logs can be backed up using eventlog_backup or as a side effect of clearing the log through eventlog_clear. The backup file can be read using the standard eventlog_open and eventlog_read commands.
-langid LANGID | Passed to the format_message command for formatting. See the description of that function for details. |
-width MAXLINEWIDTH | Passed to the format_message command for formatting. See the description of that function for details. |
-langid LANGID | Passed to the format_message command for formatting. See the description of that function for details. |
-width MAXLINEWIDTH | Passed to the format_message command for formatting. See the description of that function for details. |
-system SYSTEMNAME | Specifies the system on which the event log resides. By default, this is the local system. |
-source SOURCENAME | Specifies a event log source. The returned handle will refer to the event log to which events from SOURCENAME are logged. This defaults to the filename portion (without the path or extension) of the executable file. |
-type EVENTTYPE | Indicates the type or severity of the event. EVENTTYPE should be one of success, error, warning, information (default), auditsuccess or auditfailure. |
-category CATEGORY | This should be a integer corresponding to a category id in the event source's category or message file. This value defaults to 1. |
-system SYSTEMNAME | Specifies the system on which the event log resides. By default, this is the local system. |
-source SOURCENAME | Specifies a event log source. The returned handle will refer to the event log to which events from SOURCENAME are logged. This defaults to the filename portion (without the path or extension) of the executable file. This option may not be used with the -file option. |
-file EVENTLOGBACKUPFILE | Specifies the name of a backed up event log file. This option may not be used with the -source or -file options. |
-write | Returns a handle used for writing to the event log. By default, a read handle is returned. Note that event log handles are never read-write. Applications wishing to do both need to open two separate handles. This option may not be used with the -file option as event log backup files cannot be written to. |
-seek RECORDNUMBER | Normally the command returns event log records starting from current read pointer. If this option is specified, the command will return records starting with the one with record number RECORDNUMBER. |
-direction backward|forward | Controls the direction in which the read pointer moves. By default, the commands will return records reading forwards from the current read pointer. |
-category | This is an integer corresponding to a category id in the event source's category or message file. |
-data | Raw binary data stored as part of the event record. |
-eventid | The event id that identifies the event type. See eventlog_write for how this may be used. |
-params | A list of strings corresponding to the positional %N format specifiers in the format string for the event in the message file. |
-sid | The SID of the user account of the thread that logged the event. This may be a null string if this information was not included in the record. |
-recordnum | The record number for this record. This may be used with the -seek option to locate a record. |
-source | The event source that logged the event. |
-system | The name of the system on which the event was generated. |
-timegenerated | Contains the time that the event was generated (UTC) expressed as an offset in seconds since 00:00:00 Jan 1, 1970. This can be passed to the clock format command to convert to an absolute time. |
-timewritten | Contains the time (UTC) that the event was written into the event log expressed as an offset in seconds since 00:00:00 Jan 1, 1970. This can be passed to the clock format command to convert to an absolute time. |
-type | Indicates the type or severity of the event. The value is one of success, error, warning, information, auditsuccess or auditfailure. |
-type EVENTTYPE | Indicates the type or severity of the event. EVENTTYPE should be one of success, error, warning, information (default), auditsuccess or auditfailure. Note that the last two may only be used when writing to the Security event log. |
-category CATEGORY | This should be a integer corresponding to a category id in the event source's category or message file. This value defaults to 1. |
-loguser | Specifying this will cause the SID of the user account for this thread to be included in the event record. |
-params PARAMLIST | Specifies a list of strings corresponding to the positional %N format specifiers in the format string for the event in the message file. If the source has not been configured with a message file in the registry, event viewers will generally display this as a list of strings. |
-data DATA | Raw binary data that should be stored as part of the event record. |
Copyright © 2004, Ashok P. Nadkarni