Logic in Enterprise Library .NET 2 Logging Application Block
Posted on 2006-05-01
I am looking for some guidance on how to add logic to the Enterprise Library .NET 2 Logging Application Block.
Basically we are logging exceptions. What I want to do is if the same exception occurs multiple times within a certain timespan (say 30 seconds) then only log the first instance, not every instance.
Say a database server goes down. We get notified when a user tries to hit the web application that accesses the database. However, with a server down - even say for only 5 minutes for a re-boot, we get hundereds of identical messages all within miliseconds of each other.
Now if it is planned we can put a down message up and prevent this from happening, but if something unexpected happens we would prefer to only log the first instance, rather than have our logging flooded.
However, I cannot figure out how to put inlogic that says something like "If the last log entry of this type happend over 30 seconds ago (or if this type of log entry has never happened then log this message and keep track of it. Else do nothing - it has already been logged"
Even if I couldn't examine type, but had to say the last log entry of any type that would be oaky too.
Please be sure that any answers are for Enterprise Library for .NET 2 Logging Application Block (i.e. TraceListeners, Formatters, etc) and not using the older version (i.e. Sinks)