Top C++ Logging Libraries Compared: How to Choose the Best One - part 0

Preface

One of the most powerful tools for debugging is logging. Proper logging is crucial for keeping any application healthy and performing well. Good logs help developers track events, find issues, and understand how the system behaves in both normal and unusual situations. Poor logging, like recording too little or too much information, can either leave you unaware of problems or flood you with unnecessary data. When done right, logs offer clear, useful insights that assist in debugging, auditing, and monitoring performance. They also help diagnose production issues, making it easier to trace errors, reproduce bugs, and enhance the overall reliability of your application. In short, logging isn't just about writing messages—it's about having the right data at the right time.

In C++, there isn't a standardized logging library, and there are many options available. So, I decided to explore some of them and summarize the comparison in this blog post.

Personally, I used spdlog until now, but it is always good to explore alternative, so I’ve searched Awesome C++ for alternatives

I focused on open-source libraries with permissive licenses that handle text files only. For binary files, a log reader would be necessary, so for this blog post this is out of scope. Additionally, I searched for a good C++ interface and portability.

There are many more options, but I chose the ones with the highest ratings on GitHub.

LibraryGithub stars
spdlog~24K
glog~7K
Easylogging++~3.7K
plog~2.2K
Boost.Log~182

Setup

I am running Ubuntu 22.04 using WSL, CMake 3.29.5 and clang 19.1.2 (in order to use the C++20 format library).

Editing the example code with VSCode with WSL plugin, and running CMake from the command line.

I aim to use FetchContent feature of CMake where available, so I won’t have to deal with building the libraries by myself.

The git repository where the code is stored(meanwhile private, I will make it public as I will add a stable code).

When I got the idea for this article, I planned to do something short, like a table of several bullets, but as I delved into the details, I understood that there are too much to share, so I've decided to dedicate a separate post for each logging library.

The next post in the series will cover spdlog logging library.

Stay tuned!

Part 1 - spdlog

Part 2 - glog

Image generated with Canva

0
Subscribe to my newsletter

Read articles from Alexander Kushnir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Alexander Kushnir
Alexander Kushnir