anym0re/monolog-mysql

Laravel 8 MySQL driver for Monolog

1.0.1 2021-07-16 11:44 UTC

This package is auto-updated.

Last update: 2024-04-26 01:05:59 UTC


README

This package will log errors into MySQL database instead storage/log/laravel.log file.

Installation

composer require anym0re/monolog-mysql

Open up config/app.php and find the providers key.

'providers' => array(
    // ...
    Logger\Laravel\Provider\MonologMysqlHandlerServiceProvider::class,
);

Publish config using Laravel Artisan CLI.

php artisan vendor:publish

Migrate tables - you may want to configure enviornment beforehand.

php artisan migrate

Application Integration

In your application config/logging.php add:

use Logger\Monolog\Handler\MysqlHandler;

// ...

'channels' => [
    // ...
    'mysql' => [
        'driver' => 'monolog',
        'handler' => MysqlHandler::class,
        'level' => 'debug',
    ],
];

Environment configuration

If you wish to change default table name to write the log into or database connection use following definitions in your .env file

DB_LOG_TABLE=logs
DB_LOG_CONNECTION=mysql

Credits

Based on: