0

I have implemented Appender inheriting class in Log4cplus, which on the Append() function- opens a TCP socket and sends the event log message to a remote server, and I am wondering:

Can I make this self-implemented appender an asynchronous appender by wrapping the AsyncAppender around it (as also described here: Is Log4cplus RollingFileAppender Asynchronous or not )?

I also wonder: is the Log4cplus SyslogAppender can also become an asynchronous appender by wrapping the AsyncAppender around it the same way?

N.avraham
  • 333
  • 2
  • 15

1 Answers1

1

Yes, you can use any appender instance with AsyncAppender. Also, if you are using log4cplus 2.x, you can make any appender asynchronous by setting AsyncAppend property to true on it. In either case there is a queue that is being consumed by thread(s) that call basically call append().

wilx
  • 17,697
  • 6
  • 59
  • 114
  • And when using AsyncAppender, does the order of log events writing is kept? Is there maybe some sort of a queue that keeps events order? – N.avraham Nov 03 '18 at 21:11
  • Hi wilx, Is there a way to set/configure this queue size? I see the default queue is limited to length of 100. can I enlarge the queue? – N.avraham Nov 13 '18 at 07:44
  • 1
    @N.avraham: There is `QueueLimit` property that you can set. – wilx Nov 13 '18 at 22:10
  • Hi wilx, What exactly happens in case the Queue is full? are events lost? and if yes- then are the older or the newer ones are to be lost? – N.avraham Nov 25 '18 at 14:18
  • @N.avraham `AsyncAppender` queue blocks on a semaphore if it is full. – wilx Nov 26 '18 at 16:04