You’ve likely encountered many query issues while developing software with Laravel. You might be wondering why your features are slow or how many queries your function is making to the database. You may not know if you’re experiencing N+1 problems or how to optimize your queries. This package is here to support you with those challenges.
Install
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
Others
Custom logging channel:
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
Custom logging channel level:
SQL_LOG_LEVEL=debug
show more: https://github.com/bri4n0/sql-query-log
Top comments (0)