Free — no signup required

Introduction: The "Grep" Dead End

2 min read

The Problem with Strings

Think of a traditional log file like a diary written in plain English. If you want to find every entry where you spent more than $50 on food, you have to read every sentence and mentally parse the numbers out of prose. That's exactly what operations teams do when they grep through unstructured logs — and it breaks down fast at scale.

For decades, developers logged by concatenating strings:

logger.info("User " + username + " failed to upload file " + filename + " after " + duration + "ms")

This produces a log line like:

[INFO] User bob failed to upload file report.pdf after 1500ms

This is readable to a human skimming a terminal, but it is nearly useless for a computer trying to answer questions at scale:

  • Hard to search: Finding "all uploads slower than 1000ms" requires a brittle regular expression to extract the number 1500 from surrounding prose. The regex after (\d+)ms works until someone changes the message to "completed in 1500ms" — then your alert silently breaks.
  • No types: The number 1500 is embedded in a string. Your logging backend has no idea it is a number, so it cannot do math on it.
  • No schema: Every developer phrases messages differently. "User bob failed", "bob: upload error", and "FAILED upload for bob" are three different strings that mean the same thing — but a computer treats them as completely unrelated.

Enter Semantic (Structured) Logging

Semantic Logging treats log events as data objects, not text strings. Instead of writing a sentence, you record the facts as named, typed fields.

logger.info("upload_failed", user="bob", file="report.pdf", duration_ms=1500)

This produces structured output — almost always JSON:

{"event": "upload_failed", "user": "bob", "file": "report.pdf", "duration_ms": 1500}

The word "semantic" is key here. It means the meaning of each piece of data is explicit and machine-readable. The field duration_ms is unambiguously a duration measured in milliseconds — not because a human read the sentence and inferred it, but because the field name and its integer value encode that meaning directly.

Interview Tip

Interviewers often ask: "What's the difference between structured logging and just logging JSON?" The answer is that structured logging is a discipline, not just a format. You can dump a JSON blob and still have an unqueryable mess if the keys are inconsistent across services. Semantic logging adds schema discipline — agreed-upon field names, types, and units — so that logs from different services can be correlated and aggregated together. Mention this distinction to stand out.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free