1. Go to this page and download the library: Download exbico/monolog-db-handler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
exbico / monolog-db-handler example snippets
use Monolog\Level;
use Monolog\Logger;
use Exbico\Handler\DbHandler;
use Exbico\Handler\DbHandlerConfig;
use Exbico\Handler\Connection\PdoAdapter;
$connection = new PdoAdapter(new PDO(dsn: 'pgsql:dbname=foo;host=127.0.0.1', username: 'root', password: null));
$logger = new Logger('example',[new DbHandler(connection: $connection)]);
// You can also specify which level of messages should be logged and the table name for each level
$config = new DbHandlerConfig(
emergency: 'log_emergency',
alert: 'log_alert',
critical: 'log_critical',
error: 'log_error',
warning: 'log_warning',
notice: 'log_notice',
info: 'log_info',
debug: null, // debug level will not be logged
);
$logger->pushHandler(new DbHandler(connection: $connection, config: $config));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.