Monolog is a PHP package that routes application logs to many destinations. It implements PSR-3 so other compatible loggers can be swapped in later.
Overview
Monolog is a logging library for PHP that forwards log records to files, sockets, inboxes, databases, and various web services. Handlers, formatters, and processors can be combined to shape how records are captured and delivered.
The public API implements the PSR-3 logger interface, so libraries can type-hint against that standard and applications can replace the backend without rewriting call sites. Monolog also accepts PSR-3 log levels in its APIs while still using its own internal level scheme for compatibility with older releases.
Documentation covers handlers, formatters, processors, utility classes, extension points, and the structure of a log record. Additional handlers and formatters from the community are cataloged separately.
Many PHP frameworks and stacks integrate Monolog directly or through plugins, including Symfony, Laravel, Lumen, Drupal, Magento, Yii, CakePHP, and others noted in the project materials.
Key features
- Many built-in log handlers
- Formatters and processors
- PSR-3 compatible interface
- Accepts PSR-3 log levels
- Composable logging strategies
- Stream and file logging support
- Third-party handler ecosystem
- Framework integration options
Use cases
- Application logging in PHP projects
- Shipping logs to files or services
- Building custom handler pipelines
- Swapping loggers via PSR-3
- Framework-default logging setup