Logs
Logging pipeline
Symfony (Monolog, JSON, info level) ──► container standard error ──► Docker
│
Promtail (pch_promtail) ◄──────────┘
│
Loki (pch_loki, 1-year retention) ──► off-site copy on the recovery host
- In production, all application logs at info level (requests, e-mail sends, business events) are shipped to Loki and kept for one year.
- Errors also go to Sentry, with the context that precedes them.
- Local Docker logs are size-limited (50 MB × 5 rotation per container); Loki remains the reference.
- A guard (
loki-size-guard.sh, cron 04:30) watches the size of the Loki volume.
Read recent logs
cd ~/pch-sig
docker compose -f docker-compose.prod.yml logs --tail 100 backend
docker logs pch_backend --since 30m 2>&1 | grep -iE "error|exception|critical"
docker logs pch_traefik --since 1h 2>&1 | grep -i acme # certificates
Backend logs are JSON: | grep '"level_name":"ERROR"' isolates errors.
Query Loki
Loki listens on 127.0.0.1:3100 on the production server. From the admin workstation, open an SSH tunnel, then query the API or Grafana:
ssh -L 3100:127.0.0.1:3100 pch-prod
curl -G -s http://127.0.0.1:3100/loki/api/v1/query_range \
--data-urlencode 'query={container="pch_backend"} |= "exception"' \
--data-urlencode 'limit=50'
Sample LogQL queries:
| Need | Query |
|---|---|
| Backend errors | {container="pch_backend"} |= "ERROR" |
| E-mail sends | {container="pch_backend"} |= "SendEmailMessage" |
| Assistant answers | {container="pch_backend"} |= "Bemba: réponse" |
Useful logs by topic
| Topic | Where to look |
|---|---|
| Failed e-mails | docker exec pch_backend php bin/console messenger:failed:show |
| Grievance digest | /var/log/plainte-digest.log (production) |
| Assistant indexing | ~/assistant-indexer.log |
| SMTP relay (KoboToolbox) | docker logs smtp_relay (production): status=sent or the rejection reason |
| Pre-production backups | ~/backups/backup.log, ~/backups/gitlab-backup.log |
| Survey Solutions | ~/suso-healthcheck.log (pre-production) |
| Traefik, certificates | docker logs pch_traefik |
Application audit trail
User actions (sign-ins, changes, exports) are recorded in the application: Administration → Audits. See the user guide, Audit section.