S
S
soks2012-12-02 15:40:17
.NET
soks, 2012-12-02 15:40:17

EventLog optimization?

Hello!
There was a problem in optimizing reading from the system log:
there are over 100,000 entries, they need to be read, processed and displayed on the UI. If we take the records “on the forehead”, then the oldest ones are displayed first, in this case Linq and .Reverse () help, which, of course, simply has a monstrous effect on performance.
Perhaps someone will tell you how to pick up the most up-to-date data first?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kefirr, 2012-12-03
@soks

I have 63k records, it is the reading of the whole log that slows down. And Reverse will read everything and start returning from the end. Accessing individual records by index is fast.
Use Count and access by index.
If you want LINQ, here, for example, is a method that lists records from the end.

public static IEnumerable<EventLogEntry> EnumerateLatestLogEntries()
{
  var entries = new EventLog("System").Entries;
  for (var i = entries.Count-1; i>=0;i--)
  {
    yield return entries[i];
  }	
}

But if you need a UI that displays events (a list there or a grid), then you need to think about data virtualization. That is, for example, to load entries from the log as you scroll.

N
Nikolai Turnaviotov, 2012-12-03
@foxmuldercp

I would cache all the records somehow in my database periodically and have fun with them already ...
Again, 2998 server can generate a letter when a new event arrives in the log or even notify the admin - this can also be used so as not to keep the car every once

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question