开发者

Is Log4cplus really so slow?

I've been testing three options for my logging subsystem in C++. One is Log4cplus, one is Pantheios and the last one is a simple logging library that we have written ourselves.

Log4cplus has been much slower than the other two. Here are the results for logging 1,000,000 log entries:开发者_JAVA技巧

  • log4cplus: 200 seconds EDIT: setting the buffer size reduced it to 120 seconds
  • mylogger: 55 seconds
  • Pantheios: 35 seconds

I'm wondering if I'm missing any performance tuning.

I should add that I'm always using the root logger, I'm logging to file and logging: LOG4CPLUS_INFO(rootLogger, "Replace me with the text!");

thanks, Reza


Using log4cplus::NullAppender in the performance_test gives me Logging 1000000 took: 4sec 343709usec on semi-loaded FreeBSD server. IOW, the pure logging overhead is rather small. Your logging timings seem to depend on the target logger. If you are using log4cplus::FileAppender, the timings will be significantly different.

EDIT:

You need to tune the FileAppender a little bit. Make sure that you set the ImmediateFlush property to false. You could also set up BufferSize to something bigger, like 1000000 bytes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜