Most Python applications log like this:
logger . info ( f " Processing order { order_id } for user { user_id } " ) logger . error ( f " Payment failed for order { order_id } : { str ( e ) } " )
Enter fullscreen mode
Exit fullscreen mode
It works fine in development. In production, it falls apart.
When you're debugging a latency spike at 2am, grep-ing through gigabytes of unstructured log strings is painful. When you want to correlate a log line with the trace that generated it, you can't — the trace ID isn't in the log. When you want to count how many payment failures happened for a specific product in the last hour, you can't — the data is buried in a string.
Structured logging fixes all of this.…