Symfony Monolog Bridge
Integrates the Monolog logging library with Symfony components and services.
Repository Health
Technical Analysis
Symfony Monolog Bridge connects the popular Monolog logging library to the Symfony framework, providing a set of handlers, processors, and formatters purpose-built for Symfony applications. It lets Monolog capture and enrich log records with Symfony-specific context such as the current request, route, console command, and authenticated user, and route them to destinations like the console, email, and log servers.
As one of Symfony’s official bridge components, it is the standard integration layer used by MonologBundle and countless Symfony projects. It handles the plumbing between Monolog’s channel/handler model and Symfony’s HTTP kernel, console, mailer, and security components so logging behaves consistently across web and CLI contexts.
What You Get
- Monolog handlers tailored for Symfony: ConsoleHandler, MailerHandler, NotifierHandler, ServerLogHandler, and more
- Processors that enrich log records with request, route, console command, and security-token context
- Console and VarDumper formatters for readable, context-aware log output
- A DebugProcessor that exposes collected logs to the Symfony profiler and web debug toolbar
- Seamless integration with Symfony’s HttpKernel, Console, Mailer, and Security components
Common Use Cases
- Streaming application logs to the Symfony console with colored, formatted output
- Enriching every log record with the current request, route, and authenticated user
- Sending error-level log records via email using the Symfony Mailer handler
- Surfacing collected logs in the web profiler through the DebugProcessor
Under The Hood
Architecture - The bridge is organized by Monolog extension point: Handler/ (ConsoleHandler, MailerHandler, NotifierHandler, ServerLogHandler, ElasticsearchLogstashHandler, FingersCrossed strategies), Processor/ (WebProcessor, RouteProcessor, TokenProcessor, ConsoleCommandProcessor, DebugProcessor, SwitchUserTokenProcessor), and Formatter/ (ConsoleFormatter, VarDumperFormatter), plus a Command/ directory. Each class implements the corresponding Monolog interface and pulls context from Symfony components (HttpKernel request stack, Security token storage, Console events) so records are enriched at the point of logging. PSR-4 autoloading maps the Symfony\Bridge\Monolog\ namespace to the package root.
Tech Stack - Pure PHP requiring PHP >=8.4.1, Monolog ^3, and Symfony service-contracts and http-kernel. Dev dependencies pull in Console, HttpClient, Security, Mailer, Messenger, Mime, and VarDumper to test each integration path. Tests run under PHPUnit.
Code Quality - As an official Symfony component the code follows Symfony coding standards, is fully namespaced, and ships with a comprehensive Tests/ suite mirroring the handler/processor/formatter structure. It is developed in the Symfony monorepo (this is a read-only subtree split) with the project’s CI, static analysis, and review gates applied.
API Design - Classes follow Monolog’s well-known handler/processor/formatter contracts, so anyone familiar with Monolog can adopt them immediately. In practice most users configure the bridge declaratively through MonologBundle rather than instantiating classes directly, which keeps day-to-day usage boilerplate-free; direct programmatic use is equally straightforward thanks to consistent constructor conventions.
Used by 2 apps in this directory
matomo
Analytics
Open-source, privacy-first web and app analytics that puts you in complete control of your data.
Mautic
Automation · Marketing · Ecommerce
The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.