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,
- Is Log4Cplus RollingFileAppender asynchronous or not ?. Then what is the use of AsyncAppender ?
- Is RollingFileAppender thread safe ?
- 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 ?
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()
.
来源:https://stackoverflow.com/questions/19699956/is-log4cplus-rollingfileappender-asynchronous-or-not