Search code examples
asynchronoussysloglog4cplus

Can I use Log4cplus AsyncAppender on a self implemented appender-inheriting class?


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?


Solution

  • 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().