Answer the question
In order to leave comments, you need to log in
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
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];
}
}
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 questionAsk a Question
731 491 924 answers to any question