Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/markhilton/monolog-mysql
Laravel 5 log to MySQL database
https://github.com/markhilton/monolog-mysql
Last synced: 22 days ago
JSON representation
Laravel 5 log to MySQL database
- Host: GitHub
- URL: https://github.com/markhilton/monolog-mysql
- Owner: markhilton
- Created: 2016-07-15T13:53:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-04-12T14:53:38.000Z (over 3 years ago)
- Last Synced: 2024-12-09T16:26:48.788Z (about 1 month ago)
- Language: PHP
- Size: 18.6 KB
- Stars: 41
- Watchers: 3
- Forks: 19
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## Laravel Monolog MySQL Handler.
This package will log errors into MySQL database instead storage/log/laravel.log file.
### Installation
```sh
composer require markhilton/monolog-mysql
```Open up `config/app.php` and find the `providers` key.
```php
'providers' => array(
// ...
Logger\Laravel\Provider\MonologMysqlHandlerServiceProvider::class,
);
```Publish config using Laravel Artisan CLI.
```sh
php artisan vendor:publish
```Migrate tables - you may want to [configure enviornment](#environment-configuration) beforehand.
```sh
php artisan migrate
```## Application Integration
In your application `config/logging.php` add:
```php
use Logger\Monolog\Handler\MysqlHandler;// ...
'channels' => [
// ...
'mysql' => [
'driver' => 'monolog',
'handler' => MysqlHandler::class,
'level' => 'debug',
],
];
```# Application Integration (Laravel >= 5.6)
In your application `config/logging.php` add:
```php
[
'stack' => [
'driver' => 'stack',
'channels' => ['mysql'],
],
// [...]
'mysql' => [
'driver' => 'custom',
'via' => App\Logging\CreateMySQLLogger::class,
],
],
```In your application `app/Logging/CreateMySQLLogger.php` add:
```php
pushHandler(new MysqlHandler());
return $monolog;
}
}
```## 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
```env
DB_LOG_TABLE=logs
DB_LOG_CONNECTION=mysql
```## Credits
Based on:
- [Pedro Fornaza] (https://github.com/pedrofornaza/monolog-mysql)