# Log inspection

# Log inspection

Drillmark writes three categories of operational data. Reach for the one that matches the question.

## Container stdout / stderr (application logs)

Structured tracing emitted by the api process at `LOG_LEVEL` (default `info`).

```
docker compose logs --follow api
```

Levels and what they carry:

- `trace`, `debug`: per-request and per-job internals. Not on in production.
- `info`: job start / finish, per-source counts, successful ingestion summaries, config decisions made at boot.
- `warn`: retryable failures that recovered, parse-failures that moved an email to the `failed` folder, SMTP transient failures.
- `error`: unrecoverable per-request errors and job-level failures. Paired with a sanitized one-line message in the UI.

Docker handles log rotation; Drillmark does not. Configure the Docker log driver on the host for size and retention policies.

## Database job-run records

Each scheduled job writes one `job_runs` row per invocation and per data source. The frontend exposes these on the Jobs screen in Settings, with pagination and per-row detail. Query directly for one-offs:

```
docker compose exec --no-TTY db psql --username=dmarc_reporter --dbname=dmarc_reporter --command "
  SELECT started_at, job_type, data_source_id, status, duration_ms, error
  FROM job_runs
  ORDER BY started_at DESC
  LIMIT 20;
"
```

## Email processing logs

`email_processing_logs` records every message the pipeline touches, with its outcome (processed, duplicate, failed) and the reason. The frontend surfaces these per data source. Same pattern as `job_runs`: visible in Settings, SQL-queryable.

## What the UI shows vs what the logs show

- UI: one-line sanitized error. Safe to share with non-operators.
- stdout: the full tracing span with stack context and sanitized identifiers.

Reach for stdout for anything the UI calls "unknown error".
