tags:

views:

3794

answers:

5

I am working on a performance critical multi-threaded application. I looked at rlog, Ace and Boost logging. I chose rlog because I read it was the fastest (when logging is disabled, it has the least overhead).

The problem I have is it shows the file name, line number etc. even in release mode. If you can tell me how to shut that information off, my problem might be solved. In any case what is the most efficient logger in C++ for my situation?

+1  A: 

This article appears to address this issue very specifically.

Dave Swersky
This article gives a more in-depth explanation of what's being done in the Dr. Dobbs article you linked: http://www.inspirel.com/articles/Atomic_Log_Stream.html
Robert S. Barnes
Just started playing with the code, and it looks like the author didn't even bother to compile it before writing the article.
Robert S. Barnes
+4  A: 

I've had success with log4cxx at http://logging.apache.org/log4cxx/index.html. It's a C++ version of the popular Log4j logger, is easy to configure either via a conf file or in the code. The overhead when it is disabled is minimal (method call and integer compare).

The pattern for the output to the log is defined by a conversion pattern that can be as simple as the date/time and a message. It also handles file size limitation, rollover, etc. You can also configure different patterns for various errors and sources.

+2  A: 

Some of the overhead may happen in your macros/streams. You need to be very careful not to compose the string being logged when the logging is disabled.

Clever use of streams and ?: operator allows you to do that, as do macros.

Arkadiy
+2  A: 

maybe pantheios
though I don't know if it's thread-safe or not...

mhd
It is thread-safe
dcw
+3  A: 

Pantheios is thought to be the best performing C++ logging library, as well as claiming to be the only one that is 100% type-safe (see this article about a related library explaining why printf()/iostream-based libraries are not type-safe)

dcw