Logging, the sensible defaults

submited by
Style Pass
2024-12-25 15:30:04

Logging is a major pillar for well-designed applications. It is not only a large help during development but also critical for failure analysis and debugging.

The most effective debugging tool is still careful thought, coupled with judiciously placed print statements. - Brian W. Kernighan

Further logging is essential for observability in production. Nonetheless, I often encounter codebases with lousy logging practices. This manifests itself in useless logging missing context or in over-logging thereby bringing down the whole system. People often forget that logging is expensive. In the following I want to list the most important logging traits for modern cloud native applications.

use structured logging with a machine-parsable format like JSON with predefined properties like timestamp, environment, node, cluster, log level, app name, message, request-id

log errors with stracktrace and other context information like user-id, transaction-id, request-id. The provided context allows you to correlate logs across different systems and pinpoint issues quickly.

Leave a Comment