Skip to main content

Comparison with alternatives

The C++ logging libraries you'll actually run into differ less in "can it log" and more in how much machinery they impose before your first log line, and how much configurability they trade for that simplicity.

The field

glog (Google's logging library) is battle-tested and extremely fast at the primitives it supports, but its API predates modern C++ — no {} formatting, streams-based (LOG(INFO) << x), and comparatively few sink options out of the box.

Boost.Log is the most configurable of the group: hierarchical loggers, runtime filtering expressions, and a settings-file format, all built on Boost's usual heavy template machinery. That configurability comes with a steeper learning curve and a slower path to "logs are appearing."

log4cplus is a log4j-style port: XML/properties configuration files, appender/logger hierarchies, and rich runtime reconfiguration. It's the closest thing to Java-style enterprise logging in C++, and it feels like it.

Hand-rolled logging — a macro over std::ostream, maybe std::print in C++23 — has zero dependency cost and starts as "good enough." It stays good enough right up until you need level filtering, file rotation, or async I/O, at which point you're re-implementing spdlog badly.

Comparison table

spdlogglogBoost.Loglog4cplus
ThroughputVery highHighModerateModerate
Setup effortMinutes, header-onlyMinutes, needs a buildHours, steep APIHours, config files
Formatting syntaxfmt {}streams (<<)streams / expressionsstreams / % patterns
Config file supportNoNoYes (settings file)Yes (XML/properties)
Dependency weightLight (fmt only)LightHeavy (many Boost libs)Moderate
Async supportYes, built inLimitedYesYes
C++ standardC++11+C++11+C++11+C++11+

Choosing

When spdlog is the wrong tool

Reach for something else if you need a configuration DSL that non-developers can edit (log4cplus/Boost.Log), hierarchical logger inheritance where child loggers implicitly pick up parent settings (Boost.Log), or first-class structured/JSON events rather than formatted text lines.

spdlog gets you structured-ish logging, not structured logging

spdlog logs text lines fast; it does not model typed events. See Source location and structured logging for the custom-formatter workaround if you need JSON output.

For teams already using Boost.Log in production, Boost.Log covers the same ground from the Boost side.

See also