splash / sonata-admin-monolog-bundle
Provide a Doctrine DBAL handler for Monolog with Sonata Admin Implementation. This Bundle is inspired from LexikMonologBrowserBundle.
Installs: 624
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 17
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- knplabs/knp-paginator-bundle: >=2.3
- symfony/framework-bundle: ~2.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-12-09 21:26:25 UTC
README
This Symfony bundle provides a Doctrine DBAL handler for Monolog Web UI to display log entries is integrated to Sonata Admin UI.
You can list, filter and paginate logs as you can see on the screenshot bellow:
As this bundle query your database on each raised log, it's relevant for small and medium projects, but if you have billion of logs consider using a specific log server.
This Bundle is inspired from LexikMonologBrowserBundle
Requirements:
- Symfony 3.4+ | 4.0+ | 4.2+
- Sonata-Project/AdminBundle
Installation
Installation with composer:
... "require": { ... "splash/sonata-admin-monolog-bundle": "@stable", ... }, ...
Next, be sure to enable these bundles in your Kernel.php
file:
public function registerBundles() { return array( // SPLASH SONATA ADMIN MONOLOG BUNDLE new new Splash\SonataAdminMonologBundle\SplashSonataAdminMonologBundle(), // ... ); }
Basic Configuration
Then, you can configure Monolog to use the Doctrine DBAL handler:
# app/config/config.yml # or any env monolog: handlers: database_handler: type: service id: splash.sonata.admin.monolog.handler channels: ["!event"]
Advanced Configuration
If you don't want to use default Doctrine Entity Manager, you need to configure the Doctrine DBAL connection to use in the handler.
You have 2 ways to do that:
By using an existing Doctrine connection:
Note: we set the logging
and profiling
option to false to avoid DI circular reference.
# app/config/config.yml doctrine: dbal: connections: default: ... monolog: driver: pdo_sqlite dbname: monolog path: %kernel.root_dir%/cache/monolog2.db charset: UTF8 logging: false profiling: false splash_sonata_admin_monolog: doctrine: connection_name: monolog
By creating a custom Doctrine connection for the bundle:
# app/config/config.yml splash_sonata_admin_monolog: doctrine: connection: driver: pdo_sqlite driverClass: ~ pdo: ~ dbname: monolog host: localhost port: ~ user: root password: ~ charset: UTF8 path: %kernel.root_dir%/db/monolog.db # The filesystem path to the database file for SQLite memory: ~ # True if the SQLite database should be in-memory (non-persistent) unix_socket: ~ # The unix socket to use for MySQL
Please refer to the Doctrine DBAL connection configuration for more details.
Now your database is configured, you can generate the schema for your log entry table by running the following command:
php bin/console doctrine:schema:update --force
Translations
If you wish to use default translations provided in this bundle, make sure you have enabled the translator in your config:
# app/config/config.yml framework: translator: ~
Contributing
Any Pull requests are welcome!
This module is part of SplashSync project.