Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use EventLogReader in Desc order mode?

Im using in

  EventLogQuery eventsQuery = new EventLogQuery("Security", PathType.LogName, queryString);
  EventLogReader logReader = new EventLogReader(eventsQuery);

In order to read the log events.

I need to find the latest usage of event number #xxx ( nevermind)

But the reader begins from 1--->100

I need it to start from 100--->1 so I can get the first one (which satisfies my query) and Break the loop.

I don't want to use middleman DATA BUFFER and then reverse it.

p.s. - my log file is about 400 mb. ( win7).

like image 773
Royi Namir Avatar asked Oct 09 '11 16:10

Royi Namir


1 Answers

You could use the ReverseDirection property on the EventLogQuery class:

EventLogQuery eventsQuery = new EventLogQuery("Security", PathType.LogName, queryString);
eventsQuery.ReverseDirection = true;

EventLogReader logReader = new EventLogReader(eventsQuery);

Hope, this helps.

like image 78
Hans Avatar answered Nov 10 '22 11:11

Hans