A Laravel package for log queries in user defined log channel. Your all queries will save in the log file, and you can view it anytime.
Install the package via composer:
composer require dipenparmar12/laravel-query-log
Note: Make sure this package used only in development environment, Otherwise may you face decreased performance in production.
Optionally, you can publish the config file of this package with this command:
php artisan vendor:publish --provider="Dipenparmar12\QueryLog\StoreQueryLogServiceProvider" --tag="config"
The following config file will be published in config/querylog.php
<?php
return [
/*
|--------------------------------------------------------------------------
| Default Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for query log.
| This option defines the default log channel that gets used when writing
| Query to the logs. The name specified in this option should match
| one of the channels defined in the `config/logging.php` "channels" configuration array.
| You can define multiple channels seprated by comman (,) for query log.
|
*/
'log_chhanels' => env('QUERY_LOG_CHHANELS', null),
/*
|--------------------------------------------------------------------------
| To disable or enable the general query log.
|--------------------------------------------------------------------------
|
| This option use to disable or enable the general query log,
| Out of the box, Laravel uses the Monolog PHP logging library.
| This gives you a variety of powerful log handlers / formatters
| to utilize.
|
*/
'query_log_enable' => env('QUERY_LOG_ENABLE', true),
];
If you want to disable query log completely. change the following in .env
file
QUERY_LOG_ENABLE=false
If we want to use query logging in multiple log channels, we can archive it by following .env
QUERY_LOG_CHHANELS='single,daily'
Note: Make sure the name specified in this option should match one of the channels defined in the
config/logging.php
channels configuration array.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.