Async vs sync trade-offs
Async logging is not strictly better than sync โ it trades tail latency and complexity for
Async logging is not strictly better than sync โ it trades tail latency and complexity for
The messages you want after a failure are almost always the debug-level ones you weren't writing to
spdlog's format strings are fmt's format strings โ the same {} mini-language, with the same
The C++ logging libraries you'll actually run into differ less in "can it log" and more in how much
A runtime level check is cheap, but it isn't free โ it's still a branch and, on the disabled path,
Console output is the default destination because it's the one that always exists โ no file
There are two ways to make a logger: the factory helpers, which build a sink and register the logger
When no built-in pattern flag carries the field you need โ a request id, a thread name, a tenant โ
A custom sink is the supported way to send logs anywhere spdlog doesn't already reach โ an in-memory
Three decisions explain almost every API in spdlog: formatting is delegated to fmt, sinks are the
The simplest durable destination โ and the one whose failure modes (permissions, unbounded growth,
A log line that's still sitting in a buffer when the process dies never existed, as far as anyone
spdlog's globals โ the registry, the default logger, the registry-wide setters โ are what make the
The header-only default is what makes spdlog trivial to adopt โ copy a directory, add an include
Levels aren't one filter, they're two: a runtime one that lives per logger (and optionally per sink),
Loggers are shared_ptr-owned. The registry holds one reference, you typically hold another (or
One logger, several destinations โ this is the standard shape for a real application: everything to
The async queue is bounded, so at some point the producer (your application logging quickly) outruns
spdlog is a very fast, header-only-by-default C++ logging library built on top of
The pattern controls the line around your message โ timestamp, level, logger name, thread id โ and
The default logger exists so that adding logging to a program is one include and one call. Everything
Two different answers to "the log file cannot grow forever": rotate by size whenever the current file
The split of responsibility is deliberate: a logger decides whether to log at all, a sink decides
File, line, and function are free only if the call site captures them โ which is exactly why they're
When the platform already owns log collection โ syslog, the systemd journal, the Windows Event Log โ
The registry is a global nameโlogger map. It's what makes spdlog::get("db") work from any file in
Async logging moves formatting and I/O off the calling thread and onto a background pool โ the
For a long time, logging in C++ meant one of two things: hand-rolled iostream chains guarded by