comphp / logging-monolog
Logging Driver for CommonPHP which wraps the Monolog library for Runtime compliance
Requires
- php: ^8.5
- comphp/logging: ^0.3
- monolog/monolog: ^3.10
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpunit/phpunit: ^13.1
This package is auto-updated.
Last update: 2026-05-20 17:56:13 UTC
README
Logging driver for CommonPHP that wraps Monolog for configurable PSR-3 logging.
Requirements
- PHP
^8.5 comphp/logging:^0.3monolog/monolog
Installation
Once this package is available through your Composer repositories, install it with:
composer require comphp/logging-monolog
Usage
<?php use CommonPHP\Drivers\Logging\Monolog\MonologDriverOptions; use CommonPHP\Drivers\Logging\Monolog\MonologHandlerFactory; use CommonPHP\Drivers\Logging\Monolog\MonologLogDriver; use CommonPHP\Logging\LogManager; $handlers = new MonologHandlerFactory(); $logger = new LogManager(new MonologLogDriver(options: new MonologDriverOptions( channel: 'app', handlers: [ $handlers->file(__DIR__ . '/var/app.log'), ], ))); $logger->info('User {user} logged in.', ['user' => 'ada']);
Driver Notes
This driver is intended to let CommonPHP Logging use Monolog handlers, processors, formatters, and channels without making the core logging package depend directly on Monolog.
Applications may use this driver when they need production-ready logging targets, rotation, formatting, or integrations that Monolog already supports.
MonologLoggerFactory, MonologHandlerFactory, MonologFormatterFactory, and MonologProcessorFactory provide small helpers for common setup while still allowing applications to pass native Monolog objects directly.
Error Handling
Logger setup, handler, formatting, write, and configuration failures should throw CommonPHP logging driver exceptions when logging cannot be completed or configured safely.
Documentation
License
MIT. See LICENSE.md.