Is the event log (fast) enough for me?
Join the DZone community and get the full member experience.Join For Free
in a recent project i was required to come up with a suggestion for logging and while the existing view of using a text file is used by many popular applications and is well understood it felt like re-inventing the wheel.
in the past i have used the great libraries of enterprise library or log4net to ensure i didn’t need to re-invent the wheel but really only to ever write to a log file. i began to question should i use the windows event log rather, since it offers a lot of other features, especially around the viewer.
the viewer can not only provide a simple view, but offers ordering, filtering, exporting, remote connections (you can open the event logs on other machines), monitoring (through tools like system center operations manager ) and forwarding .
the big question for me has always been, can it cope with the load i want to throw at it? so to test this i wrote a small application, which is available for you to grab or comment on at bitbucket . the application spins up a few threads (on my machine 4 is the magic number – above that there is no major improvements) and just writes as much data as quickly as possible to an event log.
every time i have run it i have managed to get close to 40 000 writes per second! monitoring cpu at the time, it averages between 30% to 50%, so not minor load but considering how much is happening, understandable.
there isn’t much i have that needs that sort of speed, and if i do there is etw , so help me chant death to the text file, long live the event log!
Published at DZone with permission of Robert Maclean, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.