explaingit

gabime/spdlog

📈 Trending28,785C++Audience · developerComplexity · 2/5ActiveLicenseSetup · easy

TLDR

Fast, header-only C++ logging library that records program messages to console, files, or system logs with minimal performance impact.

Mindmap

mindmap
  root((spdlog))
    What it does
      Log messages
      Multiple outputs
      Async mode
    Output targets
      Console
      Files
      Rotating files
      Daily logs
    Key features
      Header-only
      Thread-safe
      Severity levels
      Custom formatting
    Tech stack
      C++11
      No dependencies
    Use cases
      Game development
      Server apps
      Debugging tools

Things people build with this

USE CASE 1

Add fast logging to a C++ game or server to track errors and performance issues without slowing down gameplay or request handling.

USE CASE 2

Set up rotating log files that automatically create new files when they reach a size limit, keeping disk usage manageable.

USE CASE 3

Enable async logging mode to hand off log writes to a background thread, preventing logging from blocking your main program.

USE CASE 4

Filter log messages by severity level at runtime to show only warnings and errors in production, but full debug output during development.

Tech stack

C++C++11

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

spdlog is a fast logging library for C++ programs. Logging means recording messages about what your program is doing, errors, warnings, debug info, so you can understand its behavior or diagnose problems. spdlog focuses on doing this with minimal impact on your program's speed. The library is "header-only," meaning you use it simply by copying its source files into your project and including them, no separate compilation or installation step is required, though package managers for various operating systems are also supported. Once included, you create named loggers and call methods like info(), warn(), error(), or debug() to record messages. You can direct those messages to the console, to plain files, to rotating log files (which automatically start a new file once a size limit is reached), to daily log files, or to the system log. Formatting is flexible, with support for rich text patterns and colored console output. A key feature is asynchronous logging: by enabling async mode, log writes are handed off to a background queue instead of blocking your program, keeping things fast. Log severity levels can be filtered at runtime or at compile time, so you can turn verbose debug output on or off without changing code. Multiple threads can share a single logger safely. The code examples in the README demonstrate creating console loggers, file loggers, rotating loggers, and custom format patterns. spdlog is written in C++ and requires a C++11 compiler. It is used when building any C++ application, games, servers, tools, where recording program activity quickly and reliably matters.

Copy-paste prompts

Prompt 1
Show me how to set up spdlog in a C++ project and create a console logger that prints info, warning, and error messages.
Prompt 2
How do I configure spdlog to write logs to a rotating file that starts a new file every time it reaches 10MB?
Prompt 3
Set up an async logger in spdlog so that logging doesn't block my main thread, and show me how to flush pending logs before shutdown.
Prompt 4
Create a custom log format in spdlog that includes timestamps, thread IDs, and colored output for different severity levels.
Prompt 5
How do I use spdlog to log to both the console and a file simultaneously, with different format patterns for each?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.