czim/laravel-json-context-logging
A Laravel logging package that adds structured JSON context to log entries, helping you attach request, user, and custom data consistently for easier debugging, filtering, and search across application logs.
Architecture fit: The package targets a real architectural gap — Laravel's default single-line log output is hard to query, and structured context (request ID, tenant, user, trace ID) is what makes logs usable in an aggregator. Its design (configurable processors enriching records, a custom logger factory, driver integration into config/logging.php) is the right shape for Laravel's channel/handler/formatter/processor pipeline. But the shape is right for 2019's pipeline. Laravel has since moved to Monolog 2 then 3, added native JsonFormatter support in channel config, and shipped first-class context APIs (Log::withContext(), the Context facade). The package's differentiator has been absorbed by the framework.
Integration feasibility: Low for a current stack. The last release is 2019-03-05, predating PHP 8, Laravel 7 through 12, and Monolog 2/3 — which added type declarations and removed legacy formatter/handler APIs a package of this vintage would compile against. Expect either a Composer constraint failure (fails fast, which is the good outcome) or an install that succeeds and then throws at runtime on a Monolog interface mismatch (the bad outcome). There is no evidence of Laravel/PHP version support beyond the 2019 matrix.
Technical risk: High, and the risk is concentration rather than severity. Three stars and zero dependents means no downstream usage to surface bugs, no community patches, no one to escalate to. An abandoned dependency in a cross-cutting path like logging is a permanent ownership transfer to us. Secondary risks: log formatters process user-controlled data, so without maintained redaction support we inherit log-injection and PII-leakage exposure in whatever the package serializes into context; and format drift is silent — a broken formatter can degrade observability without failing a request.
Key questions:
laravel/framework versions, or does it fail at install? (Run this first — it is a 10-minute answer that gates everything else.)JsonFormatter plus a context middleware cannot deliver in under ~50 lines?context — could it capture tokens, cookies, or PII by default?Stack fit: Fits only Laravel applications that (a) are pinned to a 2019-era framework, or (b) accept a vendored fork. For a modern service, the fit is conceptual: the processor-enrichment pattern is worth copying, the package is not worth depending on.
Migration path: Two viable routes, and I would not choose a third.
JsonFormatter via 'formatter' => Monolog\Formatter\JsonFormatter::class, add a middleware or Log::withContext() call to attach request ID / tenant / user, and add processors for host and environment. This is a config change plus a small middleware — days, not weeks — with zero new dependency and full upgrade safety.Compatibility: Verify PHP and Laravel constraints before anything else; then check for Monolog 2/3 interface changes; then check whether our log aggregator (ELK, Datadog, CloudWatch) parses the exact field names the package emits. Field naming is the quiet migration cost — downstream dashboards and saved searches break on rename.
Sequencing:
Maintenance: This is the deciding factor. The package is inert — no releases in six-plus years, no triage, no security response. Every future Laravel or Monolog upgrade becomes our problem to solve. Adopting it converts a trivial config decision into a standing dependency liability that we carry indefinitely for a capability the framework now provides free.
Support: No upstream support channel. Internal support burden falls on whoever owns observability, and that person must be able to debug formatter and processor behavior in the logging hot path — a specialist skill, not a generalist one. With a native implementation, the support surface is Laravel's own documented logging pipeline.
Scaling: No meaningful throughput concern. Logging volume is bounded by channel config, sampling, and sink capacity, not by this package. The real scaling question is whether enrichment adds per-record overhead in the hot path — negligible for simple context, worth measuring if processors do I/O or serialization of large objects.
Failure modes:
Ramp-up: Near zero for the native approach — any Laravel developer can read config/logging.php and a middleware. For the package, ramp-up is deceptively easy and then steep: the initial config is simple, but understanding what the processors do, what they serialize, and why a formatter broke after a framework bump requires reading unmaintained source. The honest framing for stakeholders: this package's best use is as a reference design for an internal logging standard, not as a dependency. Given a 3-star, zero-dependent, seven-year-stale footprint in a cross-cutting path, the recommendation is to harvest the pattern and implement it natively — the cost is small, the exit path is immediate, and we avoid accruing dependency debt for a problem Laravel already solves.
How can I help you explore Laravel packages today?