Async logging is commonly assumed to make logging cheaper, but it only redistributes the cost rather than eliminating it. The real pipeline includes a capture step (copying or serializing data) before enqueuing, which is required for correctness due to data lifetime issues with deferred formatting. Formatting often dominates logging cost, and moving it to a background thread doesn't make it faster. A single backend thread creates a hard throughput ceiling, and queues only delay when overload becomes visible. An alternative approach — optimizing formatting on the caller thread and only offloading I/O asynchronously — avoids lifetime issues, reduces copying, and produces more predictable behavior.
2 Comments
Sort: