geo6 / mezzio-monolog
Mezzio Monolog ErrorHandler
Installs: 4 174
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- laminas/laminas-dependency-plugin: ^2.1
- laminas/laminas-servicemanager: ^3.4
- mezzio/mezzio: ^3.2
- monolog/monolog: ^1.24 || ^2.0
Requires (Dev)
- phpstan/phpstan: ^0.12.56
- phpstan/phpstan-strict-rules: ^0.12.5
- sentry/sdk: ^3.0
- squizlabs/php_codesniffer: ^3.4
Suggests
- sentry/sdk: Allow sending log messages to Sentry.io
This package is auto-updated.
Last update: 2024-12-22 17:12:45 UTC
README
This library enables Monolog as ErrorHandler in Mezzio.
Currently, there are 2 handlers supported (more will be added if needed):
StreamHandler
: Logs records into any PHP stream, use this for log files.SentryHandler
: Logs records to Sentry.io (requiressentry/sdk
package).
Install
composer require geo6/mezzio-monolog
Configuration
Create a monolog.global.php
file in your config
directory:
<?php declare(strict_types=1); return [ // StreamHandler 'stream' => [ 'path' => 'data/log/myapp.log', ], // SentryHanlder 'sentry' => [ 'dsn' => 'https://xxxxx@sentry.io/12345', ], ];
Usage
To enable it, you just have to add Geo6\Mezzio\Monolog\ConfigProvider::class
to your main configuration (usually config/config.php
):
...
$aggregator = new ConfigAggregator([
+ Geo6\Mezzio\Monolog\ConfigProvider::class,
...
], $cacheConfig['config_cache_path']);
...
The Monolog ErrorHandler will be active only in "production mode" (when $config['debug]
is false
).
To switch to "production mode", you can use composer run development-disable
.