I have developed a MFC
application which reads windows event logs
from event log file
(EVTX
) file and parse it to render in application
For reading log file, I am using XPATH
query to retrieve specific event logs from event log file
file consist of 40000 records
Sample log records look like below code
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Error_Log"/>
<EventID Qualifiers="20225">6002</EventID>
<Level>4</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2018-05-31T10:37:16.000000000Z"/>
<EventRecordID>11679958</EventRecordID>
<Channel>Application</Channel>
<Security/>
</System>
<EventData>
<Data>16:07:16.339:(A)[app.exe] [scan] m_id = [1254]</Data>
<Binary>31363A30373A31362E3333393A2841295B7275706170702E6578655D205B5363616E5D206D5F6964203D205B313235345D</Binary>
</EventData>
</Event>
Here I want to retrieve only those log records where <DATA>
tag contains sub-string value m_id
. To achieve this I tried below query
LPWSTR Query = _T("Event/EventData[Data(Data='m_id')]");
EVT_HANDLE Results = EvtQuery(NULL, Path, Query, EvtQueryFilePath | EvtQueryForwardDirection);
But I am not able to retrieve any logs even if string m_id
is present in input log file as shown in above code