Is Log4cplus RollingFileAppender Asynchronous or n

2019-05-18 03:47发布

问题:

I'm going to add Log4cplus for our application. Our application is written in C++ and it is multithreaded. I want to use the Log4Cplus RollingFileAppender for the same.

I know Log4Cplus was derived from Java Log4j. As I didn't know Java well, I have no idea on Log4j.

My questions are as follows,

  1. Is Log4Cplus RollingFileAppender asynchronous or not ?. Then what is the use of AsyncAppender ?
  2. Is RollingFileAppender thread safe ?
  3. Do I need to handle code for thread safety with RollingFileAppender or is it inbuilt ?

Also can some one point me some examples for multi threaded rollingfileappender ?

回答1:

RollingFileAppender is thread safe and it is not asynchronous. To get asynchronicity, you would have to wrap the AsyncAppender around it. There is nothing special about using RollingFileAppender from multiple threads when compare to single thread. Synchronization is done for all appenders in Appender::doAppend().