Wednesday, November 05, 2008

new lib of choice: log4cxx

During the last couple of weeks I've been evaluating various logging libs. The finalists were rlog-1.4 and log4cxx-0.10.0.

Inspired by the Panthios performance comparison, I've concocted my own performance test to decide what should I use: rlog or log4cxx. The test was also good to better understand the two libs and see what's the complexity to achieve similar results with them.

Instead of the tests from Pantheios, I've used these:
  • Scenario 0 No Logging (used to get a reference for the other tests)
  • Scenario 1 A single string.
  • Scenario 2 Several string instances
  • Scenario 3 Several numeric type instances.
  • Scenario 4 A custom type `Person`.
  • Scenario 5 A composite scenario, based on the previous scenarios.
  • Scenario 6 Multiple log channels, instantiated by a large number of objects, with messages only on a couple of channels (this should indicate the impact of having a new log channel defined in each class)
The tests were run logging to a file descriptor. To distinguish between lib performance and disk performance, the tests were run once logging to /dev/null and once to a real file.

Each test was also repeated for 2 types of logging formats: ttcc (this uses the TTCC log class from Log4cxx) and rlog (this uses a custom format logger from Log4cxx that outputs a text similar with that generated by rlog).

Though rlog was always almost twice as fast compared with log4cxx, in the end I'll go with log4cxx because:
  • support for wide chars (not needed now, but nice to have)
  • text formatting is much more flexible and C++ style
  • more storage formats
  • I liked more the way I've been able to add logging at class level (this is personal, I know, and somebody might get a simpler and nicer way to add rlog to a class than I was able to)
Hopefully, log4cxx will be fast enough for my isolib and I will not regret this decision later :)

Here are the benchmark results:

No comments:

Post a Comment