Reputation: 31
Basically, I would like to be able to log events such as "HTTP timeouts" in my application only if they happen more than 100 times per minute (for example).
Is there any way to configure log4net to handle such a task?
Thanks in advance,
Upvotes: 3
Views: 214
Reputation: 15313
This looks like something you may be interested in.
log4net - any filter for logging only the Nth message?
or here's an example of throttling emails:
Upvotes: 0
Reputation: 51284
No, you cannot configure it to behave that way.
But, you can achieve this fairly easily by writing your own, custom Appender. Simply inherit from AppenderSkeleton
, and override the Append
method with your own logic (passing the event parameter to the base implementation as needed).
Any public property in your class can will be automatically loaded by log4net from the configuration file, so you can also specify the threshold rate this way.
Upvotes: 4