# Logging that helps debugging, for people and coding agents

Canonical: [Logging that helps debugging, for people and coding agents](https://contextingo.com/blog/logging-for-debugging-with-agents)

Locale: en

Purpose: 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.

Content updated: 2026-10-15

Source revision: content.ts 2026-10-15

Maintenance owner: the Contextingo site owner

[Topic map](https://contextingo.com/llm/topics/blog.md) · [Complete scoped map](https://contextingo.com/sitemap.md)

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](/blog/context-size-and-token-cost).
- Redact before sharing.

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

## Questions

### 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.
