I'm trying to design a custom filter using log4net. I'm in the conceptual stage of design and I don't see how I can implement the entire design.
The problem is that I want a part of log4net, a filter, to be able to generate logging entries. I want to make a filter that will suppress identical log messages from the same logger if they occur too soon after each other, and then emit a log entry when the error condition stops. I'll illustrate with an example. An external device is polled once a second. The device begins to return errors. The logger calls the Error method. The first error is logged as usual. The device then returns the exact same error once a second for 10 minutes. The filter denies all of those entries because they are identical to a log entry that was logged within a specific expiration period (configurable aspect of filter, in this example, let's say 2 minutes). I think I can do what's above. The kicker is the final part, illustrated below. One expiration period (2 minutes in this example) after the last identical log entry was denied by the filter, the filter generates a log entry stating that the error message X had occurred Y times and the last occurrence was at Z time. This entry should be logged from the same logger that made all the identical log entries. I haven't written any code for this because I want to know that it's feasible. I'm not sure how to get the class that implements IFilter to generate a log entry from the same logger that submitted the original entries. Any ideas? Thanks for reading this... The information transmitted (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is intended only for the person(s) or entity/entities to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer.
