klaravel / db-logger
Laravel database/sql queries logger.
Installs: 2 353
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 4
Forks: 1
Open Issues: 2
Requires
- illuminate/support: 5.*
This package is not auto-updated.
Last update: 2024-11-09 21:17:10 UTC
README
This module allows you to log SQL queries (and slow SQL queries) to log file in Laravel framework. It's useful mainly when developing your application to verify whether your queries are valid and to make sure your application doesn't run too many or too slow database queries.
Installation:
-
Run
composer require klaravel/db-logger
in console to install this module
-
Open
config/app.php
and inproviders
section add:Klaravel\DbLogger\ServiceProvider::class,
-
Run:
php artisan vendor:publish --provider="Klaravel\DbLogger\ServiceProvider"
in your console to publish default configuration files
-
Open
config/dblogger.php
file and adjust settings to your need (by default it uses.env
file so you can skip this step if you want). -
In your .env file add the following entries:
DB_LOG_QUERIES=true # if not needed make it false DB_LOG_SLOW_QUERIES=true # if not needed make it false DB_SLOW_QUERIES_MIN_EXEC_TIME=100 DB_LOG_OVERRIDE=false DB_LOG_DIRECTORY=logs/db DB_CONVERT_TIME_TO_SECONDS=false DB_LOG_SEPARATE_ARTISAN=false
and adjust values to your needs. If you have also
.env.sample
it's also recommended to add those entries also in.env.sample
file just to make sure everyone know about those env variables. Be aware thatDB_LOG_DIRECTORY
is directory inside storage directory. If you want you can change it editingconfig/dblogger.php
file.
Note:
Make sure defined
DB_LOG_DIRECTORY
directory should be exists default direcotry is\storage\logs\db\
else application will throw error.