Monolog
The PSR-3 logging library that sends PHP logs to files, sockets, databases, and dozens of web services
Repository Health
Technical Analysis
Monolog is the de facto standard logging library for PHP, implementing the PSR-3 logger interface so that applications and libraries can log against a common contract and swap implementations freely. It ships with over 70 handlers covering local files, syslog, Slack, Sentry, Elasticsearch, AWS services, email, Redis, and many other destinations, plus a processor system for enriching log records with context like memory usage, request IDs, or stack traces before they’re written.
With more than 21,000 GitHub stars, 568 contributors, and roughly 16.5 million monthly Composer installs, Monolog ships out of the box with Symfony, Laravel, and Lumen, and is usable in virtually every other PHP framework via community bridges. Its handler/processor/formatter pipeline architecture has become the reference design that other PHP logging libraries are compared against.
What You Get
- A PSR-3-compliant
Loggerclass usable as a drop-in dependency in any framework or library - Over 70 built-in handlers for destinations including files, syslog, Slack, Sentry, Elasticsearch, AWS, Redis, and email
- A processor pipeline for enriching log records with extra context (memory usage, web request data, introspection, tags) before they’re written
- Formatters (line, JSON, HTML, GELF, and more) to control the exact shape of emitted log output
- Built-in framework support in Symfony, Laravel, and Lumen, with community bridges for most other PHP frameworks
Common Use Cases
- Centralizing application logs from a Symfony or Laravel app into a single PSR-3 logger dependency
- Routing error-level logs to Slack or Sentry in production while writing debug-level logs to local files in development
- Shipping structured JSON logs to Elasticsearch or a log-aggregation service for searchable observability
- Building a library that logs internally without hard-coding a specific logging backend, by type-hinting against the PSR-3 interface
Under The Hood
Architecture — Monolog’s src/Monolog directory centers on a Logger class (implementing PSR-3) that holds an ordered stack of Handler instances; each log call walks the stack, letting handlers decide via a minimum log level whether to process the record. Processor classes run before handlers to mutate the LogRecord (adding memory usage, web/CLI context, or custom tags), and Formatter classes control how each handler serializes the final record — a clean separation that lets one log call fan out to a file, Slack, and Sentry simultaneously with independent formatting for each.
Tech Stack — Requires only PHP 8.1+ and psr/log at runtime; the extensive require-dev list (aws/aws-sdk-php, elasticsearch/elasticsearch, guzzlehttp/guzzle, mongodb/mongodb, predis/predis, rollbar/rollbar, symfony/mailer, and more) reflects optional integrations exercised only in tests for handlers targeting those services — none of them are hard runtime dependencies of the core library.
Code Quality — 94 test files back the 71 handlers and processor/formatter classes, and the project runs PHPStan (with strict rules and deprecation-rule plugins, plus per-PHP-version baseline files) as a CI gate. The UPGRADE.md and versioned CHANGELOG.md document breaking changes carefully across major versions, and 568 contributors over 2,884 commits reflect long-running community stewardship since 2011.
API Design — The core Logger/pushHandler() API is small and PSR-3-idiomatic ($log->warning('Foo')), so consumers rarely need more than a few lines to get started; complexity is opt-in and lives in configuring specific handlers (e.g. StreamHandler, SlackWebhookHandler) rather than in the logger itself, which keeps the common path simple while still exposing the full pipeline for advanced setups.
Used by 6 apps in this directory
Craft CMS
CMS
A developer-first PHP CMS with clean-slate content modeling, auto-generated GraphQL API, and a four-tier edition system that scales from solo projects to enterprise deployments.
Dokku
Devops · Hosting Control Panel
The smallest PaaS implementation you've ever seen — deploy apps via git push using Docker and Heroku buildpacks on your own server.
EspoCRM
Marketing · Ecommerce · CRM
Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.
Open Web Analytics
Analytics
Self-host your own Google Analytics alternative with heatmaps, session recordings, and full data ownership — no cloud required.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.