What is the most efficient thread safe C ++ logger?

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

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

+78
c ++ logging
Jan 13 '09 at 16:54
source share
9 answers

Unfortunately, at the moment I can not vote. As far as I can tell, never use shit like Apache log4cxx. It contains serious errors.

  • The latest version of branch 0.9 is 0.9.7 and still contains memory leaks, because each class with virtual members does not have a virtual dtor.
  • The latest version 0.10.x has lost a lot of functionality from 0.9.x and does not support backward compatibility. You have to rewrite a lot of your code.
  • The entire project is apparently not supported. Release 0.11.xx is announced for 2 years.

In my opinion, you should go up.

+23
Nov 27 '12 at 8:59
source share

Pantheios is considered the best running C ++ protocol library , and also claim to be the only one that is 100% type safe (see this article on the linked library explaining why printf () / iostream libraries are not safe for types)

+19
May 22 '09 at 1:25
source share

I had success with log4cxx at http://logging.apache.org/log4cxx/index.html . This is a C ++ version of the popular Log4j logger, it is easily configured either through a conf file or in code. The overhead when it is turned off is minimal (method call and integer comparison).

The sample for output to the log is determined by the conversion template, which can be as simple as the date / time and message. It also handles file size limits, rollovers, etc. You can also customize various templates for various errors and sources.

+9
Jan 13 '09 at 18:44
source share

You might want to consider the registration system. logog offers just that kind of functionality, but it doesn't have the implicit code dependencies that Pantheios has. logog is thread safe and provides a high degree of control over what types of messages are logged at any given time.

I am the author of logog and accompanying, so my opinion is a bit biased. But before implementing this, I looked at rlog, Pantheios, and other logging systems.

https://github.com/johnwbyrd/logog .

+8
Sep 10 2018-11-22T00:
source share

Here is how you could disable the additional information that rlog provides (e.g. file name, line number, etc.). When you initialize rlog in your main() function (or anyway), you can do the following:

 rlog::RLogInit(argc, argv); rlog::StdioNode slog (2, rlog::StdioNode::OutputColor); slog.subscribeTo( RLOG_CHANNEL("error") ); 

The second argument to StdioNode is the flags for controlling the output. Check the rlog documentation (can be generated using Doxygen) for a complete list of possible flags. The one in the example makes rlog only a color result according to severity, without adding any other information.

+8
Oct 31 '12 at 10:13
source share

Some of the overhead may occur in your macros / threads. You must be very careful not to compose a string that is logged when the log is turned off.

The clever use of threads and the ?: operator allows you to do this, as do macros.

+4
Jan 13 '09 at 21:01
source share

maybe pantheios

although I don't know if it is thread safe or not ...

+2
Jan 14 '09 at 3:55
source share

Poco has excellent registration support ...

http://pocoproject.org/slides/110-Logging.pdf

+2
Jun 17 '13 at 11:11
source share

try c-log lib, https://github.com/0xmalloc/c-log , a fast, stable and thread safe lib log for C / C ++.

+2
Sep 21 '13 at 5:10
source share



All Articles