Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

gabime/spdlog

Developer Tools

A fast C++ logging library offering header-only or compiled use, multiple sinks, formatting, and sync or async logging.

29,770
5,342
C++
NOASSERTION
12 years old

Overview

spdlog is a C++11 logging library for applications that need fast, structured log output without building their own logging layer. It ships in two forms: a header-only version and a compiled library, with the compiled version recommended for faster compile times. Formatting is built on the fmt library, and the library covers synchronous and asynchronous logging, multiple threads, runtime and compile-time log levels, custom patterns, and a range of output targets ("sinks") such as rotating files, daily files, colored console output, syslog, the Windows event log, Qt widgets, and Android logcat.

It is aimed at C++ developers who want a mature logging component rather than a full application framework. Higher-level behavior such as backtrace buffering, multi-sink loggers with per-sink levels, environment-variable level loading, MDC, and custom sink implementations is available through the headers and the linked wiki documentation.

Getting started

To use the header-only version, copy the include/spdlog folder into your build tree and compile with a C++11 compiler. For the recommended compiled version:

$ git clone https://github.com/gabime/spdlog.git
$ cd spdlog && mkdir build && cd build
$ cmake .. && cmake --build .

The example CMakeLists.txt shows how to link and consume the library. If you prefer a package manager, the README lists Debian/Ubuntu (libspdlog-dev), Homebrew, Fedora, Arch, openSUSE, vcpkg, conan, conda, and build2 commands.

A minimal program once the headers are on the include path:

#include "spdlog/spdlog.h"

int main() {
    spdlog::info("Welcome to spdlog!");
    spdlog::error("Some error message with arg: {}", 1);
    spdlog::set_level(spdlog::level::debug);
    spdlog::debug("This message should be displayed..");
}

This prints formatted lines to the default console logger. For file output, use a sink such as spdlog::basic_logger_mt("basic_logger", "logs/basic-log.txt"), or the rotating and daily file loggers described in the README examples. Wrap logger creation in a try/catch for spdlog::spdlog_ex if the log file cannot be opened.

Constraints and notes

  • Requires a C++11 compiler; the header-only mode needs the include folder, while the compiled mode needs a CMake build or equivalent package.
  • Supported platforms listed in the README: Linux, FreeBSD, OpenBSD, Solaris, AIX; Windows with MSVC 2013+ or cygwin; macOS with clang 3.5+; Android.
  • Async logging requires initializing the thread pool (for example spdlog::init_thread_pool(8192, 1)) before creating async loggers, and the overflow policy (block vs overrun) changes behavior under load.
  • MDC is documented as not supported in asynchronous mode because it relies on thread-local storage.
  • Periodic flushing with spdlog::flush_every is documented as safe only when all loggers are thread-safe (_mt) loggers.
  • The repository license is reported as NOASSERTION, so check the license file before redistribution.
  • The benchmark numbers in the README are from a specific Ubuntu machine and Intel i7-4770 CPU; they are not a guarantee for other hardware.

HotRepo's take

spdlog has been on HotRepo's C++ daily board: on 2026-11-17 it recorded 29,761 stars, 5,339 forks, and 4 new stars for that day, reaching position 6 on the C++ daily list. Earlier daily snapshots in August 2026 showed gains of 9 and 10 stars, so the recent movement is small but steady. With roughly 29.7k stars and 5.3k forks overall, it is a widely depended-on piece of infrastructure; the low daily gain fits a mature library rather than an actively marketed new project. The 2014 Hacker News thread is mostly a single question about why logging libraries differ in speed (comment), and there is no substantive discussion there to evaluate the project on.

Written by AI from the project's README, updated . The project's own docs are the source of truth.

Hacker News

Spdlog: Super fast C++ logging library
▲ 5 · 1 comment · November 4, 2014

You might also like

  1. nlohmann/jsonA header-only C++11 JSON library with STL-like syntax, serialization, binary formats, and JSON Patch support.C++50,845
  2. fmtlib/fmtA fast, type-safe C++ formatting library for replacing printf and iostreams for output and numeric formatting.C++25,911
  3. simdjson/simdjsonA C++ JSON parser that uses SIMD instructions to hit gigabyte-per-second throughput for latency-sensitive services.C++24,455
  4. google/guavaA long-standing Java core library offering collections, concurrency and string utilities for JVM and Android codebases.Java51,914
  5. abseil/abseil-cppA C++17 library collection that extends the standard library with containers, strings, logging, synchronization and other production-tested utilities.C++18,196