When production misbehaves you may face millions of lines. Reading them well is a skill, and it starts with narrowing the search before reading anything.
Anchor on time and symptom
Decide when the problem started and what exactly is wrong: errors for one endpoint, slowness for one customer, a job that did not run. Restrict the logs to that window and that component. Compare with the period just before, since the difference is where the answer lives.
Follow one request
If logs carry a request or correlation id, take one failing request and follow it through every service. That single thread shows the sequence of events far better than skimming the whole stream.
# Find all lines for one request across files.
grep "request_id=abc123" app.log worker.log | sort
# JSON logs: show errors for one user with jq.
jq -c 'select(.level == "error" and .user_id == 42) | {time, msg}' app.json.logFind the first error, not the loudest
A failure often causes a cascade: one database timeout, then thousands of retries and secondary errors. The most frequent message is usually a symptom. Sort by time and look for the earliest unusual line.
Look at the shape
- Count messages per minute to see when it started and whether it is growing.
- Group errors by type, endpoint, version or host. If one host or one release stands out, you have a lead.
- Look for gaps. Missing logs can mean a crashed process or a dead log shipper.
Read the whole message. Stack traces and error texts usually say what is wrong. Read from the first line, note the exception class and the deepest frame in your own code, and search for the exact message.
Write logs for the person debugging
- Include identifiers: request id, user id, order id.
- Log decisions and inputs at boundaries, not every line of a loop.
- Use levels honestly, so errors mean something.
- Never log secrets or personal data you do not need.
Takeaway
Narrow by time and component, follow one request, find the earliest error, compare with a healthy period and invest in logs that make the next investigation easier.
Comments