LogReadEntry

LogReadEntry reads a specified log entry from a log file.

You can specify a filter that is used to select only entries of a desired class. The format of the filter is described by the event-filter data structure FILTERBLOCK.

Syntax
LogReadEntry(service, pReadEntry);

Parameters

 * service (ULONG) - input : The class of Logging Service:
 * Error Logging
 * All other values are reserved for future use.


 * pReadEntry (PVOID) - in/out : A pointer to the LogReadEntry parameter packet.
 * For Error Logging, this is a pointer to a LREREQUEST structure.
 * The caller can specify a filter that is used to select only entries of a desired class. The format of the filter is the same as the filter that is described in the LogOpenEventNotification API pFilter parameter. The caller also provides an entry key data structure. Entry keys are generated by this API and by the LogWaitEvent API.
 * Log File searching typically begins at the entry that follows the one that is specified within the event key. The event key is updated as new entries are read. If no event filter is provided, the LogReadEntry API will read the entry that is pointed to by the event key. The caller also has the option of starting a search at the logical beginning of the Log File.

Returns

 * rc (APIRET) - returns : Return code.
 * LogReadEntry returns the following values:
 * 0 No error
 * 520 Error LF buf too small
 * 523 Error LF invalid service
 * 524 Error LF general failure
 * 1703 Invalid data pointer
 * 1701 Invalid LF log file id
 * 1702 Invalid LF packet revision number
 * 1706 Invalid LF parm packet ptr
 * 1750 Invalid LF at end of log
 * 1751 Invalid LF flag
 * 1759 Invalid LF entry key
 * 1761 Error LF invalid packet size

Remarks
The library LFAPI.LIB must be linked with object files that use LogReadEntry.

Example Code

 * 1) define INCL_LOGGING
 * 2) include 
 * 3) include 

ULONG    service; PVOID    pReadEntry; APIRET   rc;

rc = LogReadEntry(service, pReadEntry);  The following example reads an entry from the default Error Logging log file. It searches for the first (that is, most recent) entry in the file that has a product manufacturer named "IBM" and a severity less than 4.  #define INCL_LOGGING #include  #include   #include   #include   #define ERROR_LOG_FILE_ID 1 #define START_AT_FIRST_ENTRY 0

{ ULONG service; ULONG severity = 4; ULONG entry_id = 12; LREREQUEST read_entry_packet; EVENTKEY EventKey; BYTE log_entry_buffer›2048!; ULONG log_entry_buffer_length; SUBBLOCK subblock1, subblock2, subblock3; HEADERBLOCK headerblock1, headerblock2; FILTERBLOCK filter;

UniChar *manufacturer_name = L"IBM";

service = ERROR_LOGGING_SERVICE;

/* Construct an event notification filter with 2 header blocks. */ /*  The first header block points to a single subblock. */ /*  The second header block points to a chain of two subblocks. */

filter.packet_size = sizeof(FILTERBLOCK); filter.packet_revision_number = LF_UNI_API; filter.header_block = &headerblock1;

/*-construct headerblock1-*/ headerblock1.pSubblock = &subblock1; headerblock1.pNextBlock = &headerblock2;

/*construct subblock1 of headerblock1*/ subblock1.entry_attribute_ID = LOG_ERROR_DMI_VENDOR_TAG; subblock1.comparison_operator = LOG_ERROR_EQUAL; subblock1.comparison_data_ptr = &manufacturer_name; subblock1.next_subblock = NULL;

/*construct headerblock2--*/ headerblock2.pSubblock = &subblock2; headerblock2.pNextBlock = NULL;

/*construct subblock2 of headerblock2*/ subblock2.entry_attribute_ID = LOG_ERROR_SEVERITY; subblock2.comparison_operator = LOG_ERROR_LESS_THAN; subblock2.comparison_data_ptr = severity; subblock2.comparison_data_length = sizeof(ULONG); subblock2.next_subblock = &subblock3;

/*construct subblock3 of headerblock2*/ subblock3.entry_attribute_ID = LOG_ERROR_ENTRY_ID; subblock3.comparison_operator = LOG_ERROR_GREATER_THAN; subblock3.comparison_data_ptr = entry_id; subblock3.comparison_data_length = sizeof(ULONG); subblock3.next_subblock = null;

/* Construct the LogReadEntry parameter packet. */ read_entry_packet.packet_size = sizeof(LREREQUEST); read_entry_packet.packet_revision_number = LF_UNI_API; read_entry_packet.log_file_ID = ERROR_LOG_FILE_ID; read_entry_packet.flags = START_AT_FIRST_ENTRY; read_entry_packet.pEventKey = &EventKey; read_entry_packet.pFilter = &filter; log_entry_buffer_length = sizeof(log_entry_buffer); read_entry_packet.pLogEntryBufferLength = &log_entry_buffer_length; read_entry_packet.LogEntryBuffer = &log_entry_buffer;

rc = LogReadEntry(service,          /*service*/              &read_entry_packet); /*parameter packet*/

if (rc |= 0) {    printf("LogReadEntry error: return code = %d",rc); return; } 

Related

 * LogFormatEntry
 * LogOpenEventNotification
 * LogWaitEvent