5

I need a software recommendation for a C++ logging library that:

  1. is header only (so no need to install separately)

  2. is cross-platform (Mac/Linux/Windows)

  3. is easy to use

  4. can log to file but also output to screen

  5. has multiple logging levels and a way to specify which levels to log to

1
  • I'd guess if it's header-only it's almost certainly platform-independent. On the other hand, "easy to use" is a v-e-r-y subjective criterion. Perhaps you can be more specific w.r.t. what you would like to avoid, or what you would like it to do "easily"? Also - C++11 ok or do you need more backwards-compatibility?
    – einpoklum
    May 2 '16 at 23:14
3

Here are a few options for you to consider. I can't really vouch for the first two myself because I haven't used them:

  • EasyLogging: "Single header only, extremely light-weight high performance logging library for C++11 (or higher) applications." Earlier versions support C++98.
  • Proggit: "A simple, header-only, MIT-licensed, C++ logging library" with layout "based on Google's logging library" (but no code copied from there).
  • SPDLog: "Very fast, header only, C++ logging library". From my personal experience - decent enough.

and there are more...

2
  • thanks @einpoklum, I do want something that can be used with g++ compiler.
    – user308827
    May 2 '16 at 23:42
  • 1
    All of these can be used with g++ I think.
    – einpoklum
    May 3 '16 at 8:22
2

Actually I was looking the same (plus some more requirements). Unfortunately I couldn't find a library that suited my needs so I had to write my own logging library: plog.

It has the following features:

  • Very small (slightly more than 1000 LOC)
  • Easy to use
  • Headers only
  • No 3rd-party dependencies
  • Cross-platform: Windows, Linux, Mac OS X, Android (gcc, clang, msvc, mingw, mingw-w64, c++builder)
  • Thread and type safe
  • Formatters: TXT, CSV, FuncMessage
  • Appenders: RollingFile, Console, ColorConsole, Android, EventLog, DebugOutput
  • Automatic 'this' pointer capture (supported only on msvc)
  • Lazy stream evaluation
  • Unicode aware, files are stored in UTF8
  • Doesn't require C++11
  • Extendable
1
  • You should disclose your association with the library you are offering as an answer.
    – rrirower
    Jan 11 '17 at 13:26
0

plog

Repository: on GitHub

Author: Sergey Podobry

License: MPL 2.0

In development since: 2014

Self-description: Plog is a C++ logging library that is designed to be as simple, small and flexible as possible. It is created as an alternative to existing large libraries and provides some unique features as CSV log format and wide string support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.