herdwatch-oss/monolog-ecs-formatter
Monolog ECS Formatter outputs Elastic Common Schema compliant JSON from PHP and Laravel logs, making them easier to ship to Elasticsearch, Kibana, and other ECS-aware observability tools. A lightweight drop-in formatter for structured, searchable application logging.
channel, level_name, level, and datetime — makes schema migration a non-breaking, reversible step, so it can be scheduled independently of dashboard rewrites.context blob. That directly attacks mapping explosions and field-type conflicts, which are a recurring source of index bloat, reindexing work, and query breakage.service.*, user.*, trace.*, error.*, and now network.direction fields — a prerequisite for per-customer log filtering, trace-correlated debugging, and SLO/error-rate panels built on logs rather than APM. The new Network value object specifically enables traffic-direction analysis: distinguishing inbound request logs from outbound HTTP-client telemetry in a single index, which is the query shape behind dependency/fan-out dashboards and "which upstream is failing us" incident triage.NetworkDirection enum to ECS 8.11, which converts the previously open question ("how is ECS version drift handled?") into a concrete policy: the package version, not the runtime, is our ECS version pin. That is a clean, auditable contract, but it means adopting a new ECS field set requires a package bump — worth stating explicitly in the upgrade runbook.Consider it when most of the following hold:
context arrays.network.direction field gets us there with a log-schema change alone.Look elsewhere when:
network.direction exists in both schemas, so the conceptual model transfers even if the field names do not.For executives (one paragraph): Our services emit logs in inconsistent shapes, which forces us to maintain bespoke Elasticsearch mappings and rebuild dashboards whenever a service changes what it logs. This package standardizes log output on Elastic Common Schema — the industry-standard field naming — so logs from every service land in predictable, correctly-typed fields. Its key property is that it does both formats by default: new ECS fields are added while the existing fields our current dashboards rely on are preserved, so the migration is incremental and reversible rather than a flag-day rewrite. The latest release adds network direction (inbound/outbound), which lets us separate customer-facing request traffic from the outbound calls we make to dependencies in the same index — a capability we would otherwise need tracing infrastructure to get. It is MIT-licensed, small enough to vendor and own, and now pins its field set to a named ECS version (8.11), so schema changes are explicit and reviewable. The caveat is maturity: no adoption history, so we should adopt it as a pinned, internally-reviewed dependency, not a supported third-party platform — a low-cost bet with a clear exit (fork or replace with a few hundred lines of in-house code) if it stalls.
For engineering (the honest version):
Monolog formatter plus a Symfony bundle; Laravel usage is straightforward formatter wiring. Small, auditable surface — review it in an afternoon. v0.2.1 is additive only: no breaking changes, no deprecations, safe bump from 0.2.0.context dumping: metrics, labels, text, tags, service, user, tracing, error, and now Network map to top-level ECS fields, removing the field-type conflicts that plague our current indices. Network carries network.direction for outbound HTTP-client calls and inbound request logging.NetworkDirection is a closed-set enum pinned to ECS 8.11 (inbound, outbound, ingress, egress, internal, external, unknown). Two consequences: (a) we get compile-time safety and no free-text drift, and (b) new ECS values require a package bump or a local patch — decide now which, and record it in the runbook.channel, level_name, level, datetime at the top level, so no dashboard breaks on day one. Flip it off once dashboards are ported — that flag is our rollback.network.direction on both inbound and outbound paths), a pinned tag or vendored copy, and an ECS-version-drift note that now reads "aligned to ECS 8.11 via package version" rather than "undefined."How can I help you explore Laravel packages today?