An Ode to Logging

📅 Mon, Sep 2, 2024 ⏱️ 2-minute read
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Oh, log, a nerdy scribe,
In you, all errors hide.
To write it well - not an easy quest,
Let's see how we can do it best!

True hackers always start with print()
Don't judge! They've got no time this sprint.
But push to prod - a fatal flaw.
Use proper logger - that's the law!

Distinguish noise from fatal crash -
Use Info, Error, Warn, and Trace.
Put a clear level in each line,
To sift through data, neat design!

You log for humans, this is true...
But can a machine read it too?
Structure is key, JSON, timestamp...
Grafana tells you: "You're the champ!"

Events, like books, have start and end.
Use Spans to group them all, my friend.
Then take these Spans and build a tree,
We call it Trace, it's cool agree?

Redact your logs: remove emails,
addresses, PII details.
Or data breach is soon to come,
and trust me, it's not fun :(

In modern distributed world,
Do centralize your logs, my Lord.
Retention policy in place?
Or cloud bill you will embrace!

(No LLMs have been used to write this)

Feedback

As always, please reach out to me on X with questions, corrections, or ideas!