Should application logs be categorized by code layer or by domain event name?
11:39 03 Sep 2026

We maintain a Laravel 8 POS/restaurant API. Today our "log types" are mapped from route names to ~250 integer constants (e.g. account.close → type id 39). The map is hard to maintain and already has an UNKNOWN fallback when routes are missing.

We are redesigning structured logging (Monolog JSON) and need a taxonomy for each log line.

Two approaches we are considering

A — By code layer

Categories like: controller, service, repository, job, event, integration.

Idea: the field answers "which layer emitted this log?"

B — By domain event nature

Fields like:

  • type: http | job | command | integration
  • event: stable name such as account.closed, integration.pay.failed
  • component: class name (debug only), e.g. AccountService

Idea: the primary field answers "what happened in the business/domain?"

We know ECS / OpenTelemetry lean toward event-oriented fields (event.action, etc.), but we want practical trade-offs for a single Laravel monolith, not microservices theory.

advice php laravel laravel-8