Is Log4cplus So Slow?

I tested three variations of my C ++ logging subsystem. One of them is Log4cplus, one is Pantheios, and the last is a simple registration library that we ourselves created.

Log4cplus was much slower than the other two. The following are the results of registering 1,000,000 journal entries:

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

I am wondering if any performance tuning is missing.

I must add that I always use the root log, I register the file and register: LOG4CPLUS_INFO(rootLogger, "Replace me with the text!");

thanks reza

+8
c ++ performance logging log4cplus pantheios
source share
1 answer

Using log4cplus::NullAppender in performance_test gives me Logging 1000000 took: 4sec 343709usec on a semi-loaded FreeBSD server. IOW, the net logging overhead is pretty small. Your registration timings depend on the target registrar. If you use log4cplus::FileAppender , the timings will be significantly different.

EDIT:

You need to configure FileAppender . Verify that the ImmediateFlush property is set to false. You can also configure BufferSize for something more, such as 1,000,000 bytes.

+12
source share

All Articles