Laravel has no query log ecosystem. why?
composer require programming_cat/querylog
that's all you should do.
Once you installed programming_cat/querylog your sql query would have been recorded into "storage/logs/query-yyyy-mm-dd.log".
\Log::channel('querylog')->debug("QUERY!");
key | value |
---|---|
driver | "custom" |
via | \programming_cat\QueryLog\Services\CreateQueryLogger::class |
path | storage_path('logs/query.log') |
level | debug |
days | 30 |
excludes | none |
if config keys are exists in config/logging.php these variables are marged with existing variables. likely..
array_merge($packaged_config_values, $existing_config_values);
"driver" must be "custom".
"via" must be "programming_cat\QueryLog\Services\CreateQueryLogger"
define log path as you like. default variable is storage_path('logs/query.log').
log level. see monolog imprementation
set rotation days. default is 30.
regexp definition string or function returns boolean.
string
'excludes' => '^(insert|update) '
function
'excludes' => function (string $query) {
return strpos($query, 'exlude-table-name') !== FALSE;
}