Ad

How To Configure A Bufferred And Timeout Based Appender In Log4net?

- 1 answer

I want to configure a Forwarding-Appender in log4net, that does the following:

  1. It buffers up to N messages. When N is reached, its trigger is executed and it forwards its buffer. Not lossy.
  2. It forwards its buffered messages if a defined timeout is reached. So the trigger is executed also when a timeout is reached.
  3. It forwards its buffered messages when the hosting program terminates/closed.

So what I need is a composite trigger: based on count, timeout, and program termination.

How can I configure such appender, if at all?

Ad

Answer

I don't think there are any appenders available in the default distribution that do this. You'll have to roll you own, but it's not too hard to do.

Ad
source: stackoverflow.com
Ad