Guess first

You can't log in to their production.

After an incident, Northwind's ops team sends you a log export. Which kind of log line would let you find the failing request in seconds?

Your serviceOne JSON lineTheir log toolSplunk or ELKYouFilter request_id
Lesson notesLogs they can search: the short version+

Week 2 · Production Python · about 3 minutes

What you will be able to do

Write one structured, searchable log line per event, with a request ID and no personal data.

The idea

At a client you usually can't attach a debugger or open the server. Their logs, in their tool, are what you get.

Write one structured line per event: JSON with a fixed event name plus fields. Always include a request_id that travels through every call, and the facts you will filter by: status, duration, attempt, tenant.

Never log secrets or personal data. Log the account ID, not the account holder's name.

import json, logging

log = logging.getLogger("gateway")

def log_event(event: str, **fields) -> None:
    log.info(json.dumps({"event": event, **fields}))

log_event("llm_call_failed", request_id=req.id, status=503,
          attempt=3, duration_ms=10_012, tenant="northwind")

Write logs for the person debugging at 2 a.m. with nothing but search.

Key takeaways

  • JSON with a fixed event name and fields.
  • A request_id on every line, passed through every call.
  • IDs, not names; never secrets or card numbers.

Part of the Forward Deployed Engineer roadmap. New to the role? Start with what a Forward Deployed Engineer does.