sinemacula/laravel-log-cloudwatch
A Laravel logging driver that sends application logs directly to AWS CloudWatch. Integrate CloudWatch Logs with Laravel’s logging stack to centralize, monitor, and retain logs in AWS with simple configuration.
Architecture fit. sinemacula/laravel-log-cloudwatch is a narrowly scoped adapter: it registers a Monolog handler that ships Laravel log records to AWS CloudWatch Logs through the official AWS SDK. That is a good architectural match for teams already standardising observability on CloudWatch — it removes the need to run a sidecar (FireLens/Fluent Bit) or a custom handler in every service. It is a transport component, not an observability platform: it does not add structured context, tracing correlation, or sampling. Treat it as a commodity driver and keep it behind Laravel's existing config/logging.php channel abstraction so it stays swappable.
Integration feasibility. Integration is configuration-first: add a channel block, supply region/credentials/log group/stream, and route via LOG_CHANNEL or a stack channel. Effort is low (hours, not days) for a single service, contingent on three prerequisites being resolved up front: (1) the AWS SDK is already a dependency or acceptable as a new one (it is sizeable and pulls in Guzzle and supporting packages — relevant if image size or cold-start time matters); (2) the runtime has a resolvable credential chain (ECS task role, EC2 instance profile, or IRSA on EKS) rather than long-lived keys in environment variables; (3) IAM permits logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEvents, logs:DescribeLogStreams — and a decision has been made about whether the app is allowed to create groups/streams at all.
Technical risk. The dominant risk is that CloudWatch delivery happens on the logging path. Synchronous PutLogEvents calls add network latency to the request/worker lifecycle and can amplify an incident: if CloudWatch throttles or is unreachable in the configured region, logging can stall or block the request path. Mitigations to validate before adoption: buffering/batching behaviour of the handler, whether failures are swallowed or surfaced, and whether the configured channel uses tap/stack so a stderr driver remains as a fallback. Secondary risks: per-event (256 KB) and per-batch limits silently truncating large exception payloads; missing log-group creation producing a confusing ResourceNotFoundException on first deploy; uncontrolled ingestion cost with no retention policy set; and supply-chain/governance exposure on a small, single-maintainer package — warrant a dependency review and a pinned version.
Key questions.
stack + stderr for safety?Stack fit. Native fit for PHP 8.x + Laravel services on ECS/EKS/EC2 with CloudWatch as the system of record for logs. Poor fit for Lambda (where stderr/CloudWatch is already automatic and this adds redundant cost and latency), and a questionable fit where Datadog/New Relic/OpenSearch is the chosen backend. The v1.1.0 release — adding Laravel 13 support — is the relevant compatibility signal: it indicates active maintenance and gives us a forward path to Laravel 13 without forking or pinning to an older framework. It is an additive, non-breaking minor release under semver; no migration work is implied for v1.0.0 consumers.
Migration path. Adopt incrementally rather than as a cutover. Phase 1: add the package and a CloudWatch channel alongside the current driver in a stack, so both streams run in parallel. Phase 2: verify parity (message fidelity, context/exception formatting, ordering, multi-line stack traces) in staging. Phase 3: promote CloudWatch to primary in one low-risk service; retain stderr in the stack permanently as a cheap circuit breaker. Phase 4: roll out service by service.
Compatibility. Confirm composer constraints resolve against our current Laravel minor before scoping the work; do not assume Laravel 13 support means Laravel 10/11/12 are still covered. Verify PHP version floor, AWS SDK v3 compatibility with whatever the platform team pins, and whether the package's Laravel 13 support requires a framework bootstrap change (service provider auto-discovery, config publishing). Pin the version in composer.json and record the upgrade path in our platform runbook.
Sequencing. (1) Dependency and security review of the package; (2) AWS prerequisites — log groups, retention policy, IAM role/policy, region decision — owned by the platform team, not the app teams; (3) one pilot service in staging; (4) pilot in production behind the dual-write stack; (5) codify a reusable Terraform/CDK + logging.php template so subsequent services are copy-paste; (6) roll out. Steps 1–2 are the long pole and gate everything else.
Maintenance. The package itself is low-maintenance, but it sits on two moving dependencies (Laravel major releases annually; AWS SDK). Budget a small recurring review each Laravel release cycle — v1.1.0 is exactly that signal, and its absence in future cycles would be an early warning. Prefer pinning with a scheduled bump rather than floating constraints.
Support. Expect thin upstream support (small maintainer base, community-driven). Do not make this a dependency we cannot replace: keep the channel abstraction intact so a swap to stderr + FireLens or an alternative handler is a config change, not a refactor. Identify an internal owner for the logging channel template.
Scaling. Two dimensions. Volume: CloudWatch ingestion is billed per GB and grows with verbosity — set retention and log levels deliberately, and validate behaviour under high log throughput, since synchronous puts scale with request rate. Concurrency: many PHP-FPM workers or queue consumers writing to the same log stream can cause sequence-token contention and throttling; confirm the package's stream-naming strategy supports per-instance streams before load testing.
Failure modes. CloudWatch throttling or regional outage → latency or dropped logs at exactly the moment logs matter most; mitigate with the stack+stderr fallback and alerting on log-delivery errors. Credential expiry in long-lived workers → silent delivery failure; mitigate with role-based credentials and a heartbeat check. Auto-creation disabled or IAM under-scoped → no logs on first deploy; mitigate by provisioning groups out-of-band. Oversized exception payloads → truncated traces; mitigate by capping context size. Misconfigured region or group name → logs land where nobody is looking; mitigate with a post-deploy smoke assertion that a known event is queryable in CloudWatch.
Ramp-up. Low for application engineers (one config block). The real ramp is on the platform side: IAM, retention, cost guardrails, and a documented "how to add your service to CloudWatch logging" template. Estimate roughly one engineer-day for the pilot service end-to-end including AWS prerequisites, then near-zero marginal cost per additional service. Recommend a short decision record capturing the dual-write policy and the retention/cost defaults so this does not get re-litigated per team.
How can I help you explore Laravel packages today?