ebethus/laravel-mysql-log-driver
Laravel Monolog MySQL Handler.
This package will log errors into MySQL database instead storage/log/laravel.log file.
Compatible with Laravel 10, 11, and 12.
Installation
composer require itelmenko/laravel-mysql-logger
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
Publish config using Laravel Artisan CLI.
php artisan vendor:publish
Migrate tables.
php artisan migrate
Using
In config/logging.php
<?php
// [...]
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['mysql'],
],
// [...]
'mysql' => [
'driver' => 'custom',
'via' => ITelmenko\Logger\Laravel\Logging\MySQLLogger::class,
'connection' => env('DB_LOG_CONNECTION'),
'table' => env('DB_LOG_TABLE'),
'name' => 'my.channel' // optional
],
],
Somewhere in your application
Log::channel('mysql')->info('Something happened!');
TODO
Change$table->bigIncrements('id')to something like ULIDChange root namespace toITelmenkoRemoveextrafields from modelRemove updated_at?Add microseconds for created_at- Update version and readme.md (about a changing of migration, about vendor:publish)
- Add
php doc - Add phpcs
Related Packages
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v1.0.7 | >=7.3.0 | ^5.3| | MIT | |
| v1.0.6 | >=7.3.0 | ^5.3| | MIT | |
| v1.0.5 | >=7.3.0 | ^5.3| | MIT | |
| v1.0.4 | >=7.3.0 | ^5.3| | MIT | |
| v1.0.3 | >=7.3.0 | ^5.3| | MIT | |
| v1.0.2 | >=7.3.0 | ^5.3| | MIT | |
| v1.0.1 | >=7.3.0 | ^5.3| | MIT | |
| v1.0 | >=7.3.0 | ^5.3| | MIT | |
| v0.1.15 | >=7.1.4 | MIT | ||
| v0.1.14 | >=7.1.4 | MIT | ||
| v0.1.13 | >=7.1.4 | MIT | ||
| v0.1.12 | >=7.1.4 | MIT | ||
| v0.1.11 | >=7.1.4 | MIT | ||
| v0.1.10 | >=7.1.4 | MIT | ||
| v0.1.9 | >=7.1.4 | MIT | ||
| v0.1.8 | >=7.1.4 | MIT | ||
| v0.1.7 | >=7.1.4 | MIT | ||
| v0.1.6 | >=7.1.4 | MIT | ||
| v0.1.5 | >=7.1.4 | MIT | ||
| v0.1.4 | >=7.1.4 | MIT | ||
| v0.1.3 | >=7.1.4 | MIT | ||
| v0.1.2 | >=7.1.4 | MIT | ||
| v0.1.1 | >=7.1.4 | MIT |