geo6/zend-expressive-monolog

此包已被弃用且不再维护。作者建议使用 geo6/mezzio-monolog 包。

Mezzio Monolog ErrorHandler

v2.0.2 2020-11-20 13:42 UTC

README

Latest Stable Version Total Downloads Monthly Downloads Software License

此库使 Monolog 能够在 Mezzio 中作为 ErrorHandler。

目前支持 2 种处理器(如有需要将添加更多)

安装

composer require geo6/mezzio-monolog

配置

在您的 config 目录中创建一个 monolog.global.php 文件

<?php

declare(strict_types=1);

return [
    // StreamHandler
    'stream' => [
        'path' => 'data/log/myapp.log',
    ],
    // SentryHanlder
    'sentry' => [
        'dsn' => 'https://xxxxx@sentry.io/12345',
    ],
];

用法

要启用它,只需将 Geo6\Mezzio\Monolog\ConfigProvider::class 添加到您的配置文件中(通常是 config/config.php

...

$aggregator = new ConfigAggregator([
+     Geo6\Mezzio\Monolog\ConfigProvider::class,

    ...
], $cacheConfig['config_cache_path']);

...

Monolog ErrorHandler 只在 "生产模式" 下(当 $config['debug']false 时)激活。
要切换到 "生产模式",可以使用 composer run development-disable