spdlog is a C++ logging library usable header-only or compiled. It supports consoles, files, syslog, and custom sinks with sync or async modes.
Overview
spdlog is a C++ library for application logging. You can link it as a header-only dependency or use a compiled build when you want shorter compile times.
Loggers can be single- or multi-threaded, with optional asynchronous logging. Messages support custom format patterns, runtime and compile-time log levels, and loading levels from argv or environment variables. Backtrace support stores debug messages in a ring buffer for later inspection.
Output targets include rotating or daily log files, colored console logging, syslog, the Windows event log, the Windows debugger, and user-defined sinks. Multiple sinks can be combined on one logger with different formats and levels.
The library is packaged for common Linux distributions, macOS package managers, Windows toolchains, Android, and several C++ package managers. Documentation is maintained in project wiki pages.
Key features
- Header-only or compiled builds
- Asynchronous logging mode
- Custom log formatting
- Rotating and daily log files
- Colored console output
- syslog and Windows event log sinks
- Runtime log level control
- Ring-buffer backtrace support
Use cases
- Structured logging in C++ services
- File and console logging on Linux servers
- Multi-sink logging with per-sink levels
- Android native code logging
- Debugging with deferred backtrace output