Log4cplus RollingFileAppender是否异步 [英] Is Log4cplus RollingFileAppender Asynchronous or not

查看:956
本文介绍了Log4cplus RollingFileAppender是否异步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将为我们的应用程序添加Log4cplus.我们的应用程序是用C ++编写的,并且是多线程的.我想将Log4Cplus RollingFileAppender用于相同的功能.

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.

我知道Log4Cplus是从Java Log4j派生的.因为我不太了解Java,所以我对Log4j一无所知.

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

我的问题如下,

  1. Log4Cplus RollingFileAppender是否异步?那么AsyncAppender的用途是什么?
  2. RollingFileAppender线程安全吗?
  3. 我是否需要使用RollingFileAppender处理代码以确保线程安全?

也可以给我指出一些多线程rollingfileappender的示例吗?

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

推荐答案

RollingFileAppender是线程安全的,并且不是异步的.要获得异步性,您必须将AsyncAppender包装在其周围.与单线程相比,在多线程中使用RollingFileAppender并没有什么特别的.对Appender::doAppend()中的所有追加程序进行同步.

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

这篇关于Log4cplus RollingFileAppender是否异步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆