macpaw/sentry-monolog-adapter
A Monolog handler that forwards log records to Sentry as events and breadcrumbs, making it easy to capture errors and context from Laravel and PHP applications. Configurable log levels and simple integration with existing logging stacks.
Architecture fit
LogRecords into Sentry Events and calls captureEvent on a Sentry ClientInterface/HubInterface. It exists to fill the gap left when sentry/sentry removed Sentry\Monolog\Handler from the core SDK — a real, structural gap, not a cosmetic one.sentry/sentry-laravel ships and wires up in its service provider. For a standard Laravel app, adopting this package is a replacement of a working, vendor-maintained component, not an addition.Integration Feasibility
monolog log driver supports handler / handler_with and a via factory in config/logging.php, so registering a custom handler is a config change plus a small service provider binding for the Sentry client dependency. No middleware, no facade, no interception layer.Technical Risk
sentry/sentry-laravel: report-filtering of exceptions is a first-class Laravel feature. A generic adapter has no knowledge of it and will happily ship exceptions you deliberately excluded.Key Questions
monolog/monolog, sentry/sentry, and PHP version? Monolog 3 and Sentry 4+ supported explicitly, or by accident?context promoted to extra, is exception attached as Throwable, are channel/level preserved as tags, is extra filtered before serialization?isHandling() gate so LOG_LEVEL and channel-level filtering still short-circuit before Sentry work is done?reset() / close() correctly for long-running processes (Octane, Horizon, queue:work)?Stack fit
sentry/sentry-laravel; (b) you maintain a shared package that must log to Sentry without a framework dependency; (c) you need payload control the official handler doesn't give you. If none hold, the correct decision is to stay on sentry/sentry-laravel and close the evaluation.Migration path
stack → sentry_adapter) alongside the existing Sentry integration, so both emit in parallel.extra/context, breadcrumb fidelity, and — critically — the list of exception classes that reach Sentry versus the ones Laravel's report filter intends to suppress.Compatibility
handler_with / via instantiation works with the adapter's constructor — if it requires a pre-built HubInterface, you need a singleton binding in a service provider; if it accepts config only, config alone suffices.reset() clears breadcrumbs and any accumulated context between requests, otherwise you leak request data across requests in the same worker.Sequencing
composer.json constraints and the record→event mapping. Reject early if Monolog 3 / Sentry 4 are not explicitly supported.extra keys — run in CI against the Sentry test transport, not production.Maintenance
^ on this dependency. Add a dependency-bot rule that flags Sentry/Monolog bumps as requiring manual review rather than auto-merge.Support
Scaling
reset() is called. Under load this is a slow leak, not a crash — it will surface as rising RSS weeks later.isHandling() gates before captureEvent, or every Log::debug in a hot loop becomes an event-construction cost even if Sentry drops it.Failure modes
dontReport list start arriving in Sentry, inflating quota and burying real signal.context/extra wholesale; Laravel apps commonly put user IDs, emails, and request bodies in log context. Audit against the DSN's data-scrubbing rules before enabling in production.Ramp-up
sentry/sentry-laravel.How can I help you explore Laravel packages today?