To install via Composer, run:
composer require bri4n0/sql-query-log
For version <= 11: Add to section providers of config/app.php:
// config/app.php
'providers' => [
...
Bri4n0\SqlQueryLog\DataBaseQueryServiceProvider::class,
];
For version >= 11: Add to section providers of bootstrap/providers.php:
// bootstrap/providers.php
return [
...
Bri4n0\SqlQueryLog\DataBaseQueryServiceProvider::class,
];
Set enable SQL query log, Add to .env
:
ENABLE_SQL_LOG=true
- open file config/logging.php
- add channel to section channels:
'channels' => [
...,
'sql-query-log' => [
'driver' => 'daily',
'path' => storage_path('logs/queries.log'),
'days' => env('LOG_DAILY_DAYS', 14),
'replace_placeholders' => true,
],
]
- enable using sql query log channel:
SQL_LOG_CHANNEL=sql-query-log
SQL_LOG_LEVEL=debug
MIT © Bri4n0