60

I'm looking for a C++ logging framework with the following features:

  • logs have a severity (info, warning, error, critical, etc)
  • logs are tagged with a module name
  • framework has a UI (or CLI) to configure for which modules we will actually log to file, and the minimum severity required for a log to be written to file.
  • has a viewer which lets me search per module, severity, module name, error name, etc
mauris
  • 42,982
  • 15
  • 99
  • 131
Warpin
  • 6,971
  • 12
  • 51
  • 77
  • Don't have an answer, but I've looked for the same sometimes and haven't found one I like. – Michael Ekstrand Nov 15 '09 at 01:55
  • process id and thread id prove very useful for multi-threaded applications. – madrag Oct 30 '13 at 23:58
  • 10
    I'd advise against log4cxx. Unfortunately, this project seems to be dead (I only realized this _after_ I replaced my own logging framework with log4cxx and ran into some problems). I only want to mention it here, since this article is the first hit when I google for "C++ logging framework". It would be nice if the Apache Foundation mentioned the state of log4cxx on their homepage for log4cxx, so others would be warned, too. – StuartRedmann Jun 25 '15 at 14:29
  • It may not suit your purposes, but **log4cxx** is again maintained actively. – Andrew Lazarus Mar 16 '21 at 05:02

6 Answers6

12

Not sure about the configuration from a UI or CLI. I've used both of these logging frameworks at one point or other.

https://sourceforge.net/projects/log4cplus/
https://logging.apache.org/log4cxx/index.html

It wouldn't be too hard to drive your logging based on a configuration file that could be editable by hand or through a quick and dirty GUI or CLI app. Might be a bit harder to adjust these dynamically but not too bad.

Update:

It looks like the proposed Boost.Log is now in Boost 1.54 which is at a stable release. If you are already using Boost than I would take a look at it.

Martin Delille
  • 11,360
  • 15
  • 65
  • 132
Casey
  • 12,070
  • 18
  • 71
  • 107
5

No viewer but you could try pantheios. I have been using it for almost a year now and am quite happy with it.

user
  • 5,335
  • 7
  • 47
  • 63
ossandcad
  • 778
  • 5
  • 18
4

I strongly suggest Pantheios, as it's the only one that's completely type-safe, and is also very efficient. It imposes a little work on the user, in selecting the right "front-end" and "back-end", but once you've got it working, you can just fix and forget.

It doesn't provide sophisticated logging facilities - e.g. rolling files - but that's by design, because it's intended to be used in combination with other logging libraries that have more functionality (but poorer performance / type-safety).

Kleist
  • 7,785
  • 1
  • 26
  • 30
dcw
  • 3,481
  • 2
  • 22
  • 30
  • 2
    Claiming that it's "the only" type-safe logging library seems like a bit of an overstatement. Can you back that up with some information? – Tamás Szelei Nov 21 '15 at 13:59
3

If you care about performance, I suggest you check out Pantheios. In particular, it's got very high performance, and it can be used in combination with other logging libraries -- it acts as an efficient and type-safe layer between the logging library (such as log4cxx) and your application code.

Michael Mrozek
  • 169,610
  • 28
  • 168
  • 175
JamieH
  • 1,257
  • 3
  • 12
  • 19
1

You could use wxWidgets and use it's excellent class for logging. It's rather easy and straightforward. For instance, you can create a dialog which gathers all your logs (e.g. wxLogError, wxLogMessage, wxLogDebug, etc.).

nhaa123
  • 9,570
  • 11
  • 42
  • 63
1

Pantheios is a good candidate in term of perormance but my personal preference is P7 library. My internal tests (CPU i7-4870HQ, SSD) shows that P7 is faster than Pantheios.

  • Pantheios writes 1.8M logs lines per second (time & text message)
  • P7 writes 2.4M logs lines per second (time, thread, CPU core, function, file, line and text message)
Igor
  • 21
  • 1
  • can you expand on it's uses? Have you had any pain points with P7? The development moved from google code but has not been put onto another platform (e.g. GitHub, BitBucket etc...), any idea why? It looks good but I have concerns over the communication and visibility of the project. – Dennis Jan 19 '16 at 14:56
  • **Uses**: time-critical applications, embedded systems, games. Useful for observing multiple application/devices at the same time, especially when telemetry is used. **pain points**: perhaps it is log formatting like ("Value=%d", myVal); Have to be careful. **GitHub, BitBucket**: haven't any idea, you may ask author. – Igor Feb 07 '16 at 11:31
  • 1
    **Communication**: as far as I know communication protocol is based on UDP and there is no encryption by performance reasons. – Igor Feb 07 '16 at 11:39
  • thanks. I meant communication among the project's development team :) – Dennis Feb 08 '16 at 09:36