Skip to content

Logging that helps when you debug, for people and for coding agents

Useful logs are structured, have levels and context, and leave out secrets. What to log, what not to log, and how to make logs readable by an agent.

Published by Contextingo.

When something fails, logs are often the only record of what happened. An agent that debugs from logs needs the same things a person does.

What good logs have

  • Structure: one event per line in a consistent format, such as JSON.
  • Levels: error, warn, info, debug, used consistently.
  • Context: request id, user or tenant id, the operation and its outcome.
  • Time in UTC with a time zone, to the millisecond.
  • Errors with causes: the message and the stack, not only “failed”.

What to leave out

  • Passwords, tokens, keys and other secrets.
  • Personal data you do not need. Log an id, not an email address.
  • Whole request bodies by default.

Make them easy to hand over

  • When you give logs to an agent, include only the relevant time window.
  • Large logs cost tokens on every turn. See context size and token cost.
  • Redact before sharing.

Contextingo’s own rule is the same: never put secrets in logs or audit data.

Questions

Good to know.

Which level should I use for expected failures?

Usually warn or info. Reserve error for things that need attention.

Should logs be in JSON?

It makes them searchable by tools and agents. Human-readable output can be a separate format for development.

Nothing learned is lost. Nothing unchecked is done.