HomeBackend Development › Logging

Logging

Purpose: Log usefully in AEM: logger configuration, per-package levels, and what belongs at each level.

Who this page is for

AudienceWhy it matters to you
Backend engineersDaily
Ops engineersLog routing

Mechanics

SLF4J everywhere: private static final Logger LOG = LoggerFactory.getLogger(PlanCardModel.class); Logs land in crx-quickstart/logs/error.log by default; Sling log configs (OSGi configs) route packages to files and set levels per environment.

# ui.config: org.apache.sling.commons.log.LogManager.factory.config~phi.cfg.json
{
  "org.apache.sling.commons.log.names": ["com.academy.phi"],
  "org.apache.sling.commons.log.file": "logs/phi.log",
  "org.apache.sling.commons.log.level": "info"
}

Per run mode: debug in dev, info in stage, warn+ in prod for your packages.

Level discipline

LevelBelongs there
ERRORBroken functionality needing action; always with the exception object
WARNDegraded/unexpected but self-healing (missing optional config, retry succeeded)
INFOLifecycle landmarks (sync started/finished, N items) — low volume
DEBUGDiagnosis detail — safe to enable in prod briefly without flooding

Rules

Quick navigation