Developer & Data Platforms

Structured logging

Also known as: JSON logging, semantic logging, structured logs

Structured logging means writing log entries as consistent, named fields, usually in JSON, rather than as free-form sentences.

Instead of 'User 42 failed to log in,' a structured log records user_id: 42 and event: login_failed. While it looks like a small formatting change, it turns logs from something humans scroll through into data machines can query, which matters enormously at scale.

Structured logging, explained at three levels

At home

Imagine keeping a diary as a messy paragraph versus filling in a form with labelled boxes: date, place, mood. The form is much easier to search later. Structured logging is the form version for software.

At work

Structured logs make it easy to answer questions like 'how many payment errors did customers in Ontario see yesterday?' without writing complex search patterns. That speeds up troubleshooting and reporting.

Real-world examples

At home

Aisha's hobby web app kept crashing at random. After switching to structured logs, she filtered by error type and request path in seconds and saw every crash came from one image upload page.

At work

Fatima manages operations at a Calgary logistics company. A regulator asked for every failed delivery notification over six months. Because the logs were structured, her analyst ran one query instead of spending days parsing text files.

How it compares

featureStructured loggingPlain-text logging
FormatNamed fields, often JSONFree-form sentences
SearchingFilter by exact fieldsText search and patterns
Human readabilityNeeds a viewer for comfortEasy to read directly
Analysis at scaleFast and reliableSlow and error-prone

Structured logs are written for machines first, which ultimately helps humans too.

For analysts

Logs are often the evidence in audits and incident reviews. I'd agree on standard fields and a list of forbidden ones, like passwords and health data, before rolling structured logging out, because fixing leaked data later is far harder.

History & origin

Unix systems standardized on syslog in the 1980s, which recorded mostly free-text messages. As log volumes exploded with web services, teams relied on fragile regular expressions to extract meaning. The syslog standard RFC 5424, published in 2009, added structured data fields, and libraries such as Logback, Serilog, and Go's zap made JSON logging easy in the 2010s. Log platforms such as Splunk, the ELK stack, and later cloud services rewarded structured data with faster search. Go added structured logging to its standard library with log/slog in 2023, and OpenTelemetry defined a common log data model. In my opinion, any team still parsing free-text logs with regular expressions is paying a tax every day.