Reputation: 1241
I am building a web application that will pull event logs from multiple servers and display them into a page that I have set up. I have set it to go back 20 events for both the Application log and the System log. However, I am trying to decide if I want to save the data to a SQL database and display it from there or directly from the server into a list box. I was leaning towards directly to the list box just because the data changes so frequently. Does anyone have any suggestions or benefits from doing this any other way?
Just in case anyone is curious, here is the code I am using:
string LogType = "Application";
string serverIP = "192.168.1.5";
EventLog eventLog = new EventLog(LogType, serverIP);
int LastLog = eventLog.Entries.Count;
int i;
for (i = eventLog.Entries.Count - 1; i >= LastLog - 20; i--) {
EventLogEntry CurrentEntry = eventLog.Entries[i];
}
Upvotes: 1
Views: 612
Reputation: 1423
I actually don't see any benefits to save the logs to the database. If you're planning to serve a lot of requests from your application, you should consider caching them in your server (and I would try to do it in memory, and not in DB), and refreshing this cache from time to time. Even if your server handles few requests - it could be useful to cache the events, just for not hitting the target servers too much.
Since this data (events) seem to me a volatile in nature, and can be easily regenerated (by querying the target machines) at any time, and changes frequently - there is no need to persist it.
Upvotes: 3