exbico / monolog-db-bundle
Symfony MonologDb Bundle
2.0.1
2024-06-13 11:27 UTC
Requires
- php: ^8.0
- doctrine/dbal: ^2.9|^3.0
- exbico/monolog-db-handler: ^1.0|^2.0
- symfony/console: ^5.0|^6.0
- symfony/framework-bundle: ^5.0|^6.0
- symfony/monolog-bundle: ^3.7
Requires (Dev)
- phpstan/phpstan: ^1.10
- slevomat/coding-standard: ^8.12
- squizlabs/php_codesniffer: ^3.7
README
安装
安装此扩展的首选方式是通过composer。
composer require exbico/monolog-db-bundle
您的捆绑包应该会由Flex自动启用。如果您不使用Flex,您需要手动通过在项目的config/bundles.php
文件中添加以下行来启用捆绑包
Exbico\MonologDbBundle\ExbicoMonologDbBundle::class => ['all' => true],
配置
config/packages/exbico_monolog_db.php
的示例,使用默认值
<?php use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->extension( 'exbico_monolog_db', [ 'connection' => 'doctrine.dbal.connection', 'levels' => [ /** The key-value array, where the key is the name of the level, * and the value is the name of the table to save logs to. * A Null value means that this level is not processed. */ 'emergency' => 'log_emergency', 'alert' => 'log_alert', 'critical' => 'log_critical' 'error' => 'log_error', 'warning' => 'log_warning', 'notice' => 'log_notice', 'info' => 'log_info', 'debug' => 'log_debug', ], 'rotation' => [ 'history_size' => 2, 'date_format' => 'YmdHis', ], ], ); };
config/packages/monolog.php
的示例
<?php use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->extension( 'monolog', [ 'handlers' => [ 'db' => [ 'type' => 'service', 'id' => 'exbico_monolog_db.handler', 'level' => 'debug', ], ], ], ); };
用法
初始化表
bin/console log:init
旋转表
bin/console log:rotate