c# - Reading remote Windows event logs takes a very long time -


i have written c# program connects remote host , reads windows event logs.

system.diagnostics.eventlog eventlog = new system.diagnostics.eventlog(); eventlog.log = "application"; eventlog.machinename = "remotemachinename"; if (eventlog.exists(eventlog.log, eventlog.machinename)) {     foreach (eventlogentry entry in eventlog.entries)     {         console.writeline(entry.message);     } } 

however, due extremely large number of events, when run code, takes time fetch eventlog.entries.

update: there way read logs since particular time (say, logs created since past 1 hour) instead of reading logs? plan read logs , later filter logs created since past 1 hour, not solution.

the short answer no. eventlog class offers no way take last x entries or entries past y date or effect. additionally you're not allowed receive eventwritten event remotely me gives 1 simple far ideal work around limit logs size. if you're consistently pulling log don't need archival purposes anyway, if limit it's time/size you'll never reading data app remain fast.

as other folks suggested in comments other reasonable option build middle layer send eventwritten events on http or central server.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -