exbico / monolog-db-bundle
Symfony MonologDb Bundle
Installs: 1 438
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^8.0
- doctrine/dbal: ^2.9|^3.0
- exbico/monolog-db-handler: ^1.0|^2.0
- symfony/console: ^5.0|^6.0|^7.0
- symfony/framework-bundle: ^5.0|^6.0|^7.0
- symfony/monolog-bundle: ^3.7
Requires (Dev)
- phpstan/phpstan: ^1.10
- slevomat/coding-standard: ^8.12
- squizlabs/php_codesniffer: ^3.7
README
INSTALLATION
The preferred way to install this extension is through composer.
composer require exbico/monolog-db-bundle
Your bundle should be automatically enabled by Flex. In case you don't use Flex, you'll need to manually enable the bundle by adding the following line in the config/bundles.php
file of your project:
Exbico\MonologDbBundle\ExbicoMonologDbBundle::class => ['all' => true],
CONFIGURATION
Example of config/packages/exbico_monolog_db.php
with default values
<?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', ], ], ); };
Example of 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', ], ], ], ); };
USAGE
Initialize the tables
bin/console log:init
Rotate the tables
bin/console log:rotate