wazaari/monolog-mysql
Monolog handler that writes Laravel and PHP log records straight to MySQL. Ships with a ready-made schema, configurable table and connection, buffered bulk inserts for speed, and level filtering. Drops into Laravel's logging stack with minimal setup.
Architecture fit
illuminate/log, so a Monolog handler is the correct integration seam. A custom channel using driver => monolog can add MySQL persistence without changing application logging calls.INSERT per log record. That is simple and transparent, but it couples the request path to MySQL availability, latency, and connection limits. MySQL is not a log-native store: no ingestion pipeline, compression, retention, or multi-service aggregation.Integration feasibility
PDO instance and table/column configuration. Laravel does not bind PDO by default, so integration needs a service provider binding or a small handler factory. Laravel’s handler_with positional construction is awkward for a PDO-first constructor; a wrapper is cleaner.TEXT/JSON, DATETIME(6)), utf8mb4, and indexes. Column mapping and JSON-encoded context/extra are the main customization points.Technical risk
LogRecord. If the constraint is Monolog 1/2 only, Laravel 10/11 adoption is blocked without a fork or patch.write() can turn a log call into a 5xx or added latency unless wrapped with WhatFailureGroupHandler or an equivalent fail-open guard.max_allowed_packet limits, and PII exposure in context/extra are all foreseeable.Key questions
Stack fit
INSERT credentials. Resolve PDO lazily through a wrapper so reconnects and Octane worker recycling are handled outside the package.mysql channel in config/logging.php and attach it to the stack channel for dual-write during rollout.Migration path
artisan tinker.daily/single channel; file logs remain authoritative.Compatibility
monolog/monolog and Laravel versions explicitly; add composer audit and Dependabot.write() to accept LogRecord, add a PHP/CI matrix, and publish via private Packagist or Satis. Estimate one to three days.Sequencing
Maintenance
Support
INSERT per record, JSON encoding of context/extra, table and column mapping.Scaling
INFO+ in production, sample debug events, use FingersCrossedHandler or BufferHandler, offload to a queue, partition by day, retain 7–30 days, and isolate the logging database on separate disk/instance.channel, level, datetime) and rely on partition pruning for retention.Failure modes
WhatFailureGroupHandler or a try/catch wrapper.max_allowed_packet overflow, invalid UTF-8, or JSON encode failure: lost or truncated records. Alert on handler exceptions and track dropped-log counters.utf8mb4.DELETE ranges.INSERT, encrypt at rest where required, and audit access.Ramp-up
How can I help you explore Laravel packages today?