saint / laravel-logger
Log SQL/Cache queries in Laravel/Lumen framework
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/saint/laravel-logger
Requires
- illuminate/support: 5.*
This package is not auto-updated.
Last update: 2025-10-20 21:27:06 UTC
README
This module allows you to log SQL queries (and slow SQL queries) to log file in Laravel/Lumen 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
Laravel 5.*
- 
Run composer require mnabialek/laravel-sql-loggerin console to install this module 
- 
Open config/app.phpand inproviderssection add:Mnabialek\LaravelSqlLogger\Providers\ServiceProvider::class, 
- 
Run: php artisan vendor:publish --provider="Mnabialek\LaravelSqlLogger\Providers\ServiceProvider" in your console to publish default configuration files 
- 
Open config/sql_logger.phpfile and adjust settings to your need (by default it uses.envfile so you can skip this step if you want).
- 
In your .env file add the following entries: SQL_LOG_QUERIES=true SQL_LOG_SLOW_QUERIES=true SQL_SLOW_QUERIES_MIN_EXEC_TIME=100 SQL_LOG_OVERRIDE=false SQL_LOG_DIRECTORY=logs/sql SQL_CONVERT_TIME_TO_SECONDS=false SQL_LOG_SEPARATE_ARTISAN=falseand adjust values to your needs. If you have also .env.sampleit's also recommended to add those entries also in.env.samplefile just to make sure everyone know about those env variables. Be aware thatSQL_LOG_DIRECTORYis directory inside storage directory. If you want you can change it editingconfig/sql_logger.phpfile
- 
Make sure directory specified in .envfile exists in storage path and you have valid file permissions to create and modify files in this directory
Lumen 5.*
- 
Run composer require mnabialek/laravel-sql-loggerin console to install this module 
- 
Open bootstrap/app.phpand add:$app->register(Mnabialek\LaravelSqlLogger\Providers\ServiceProvider::class); 
- 
In your .env file add the following entries: SQL_LOG_QUERIES=true SQL_LOG_SLOW_QUERIES=true SQL_SLOW_QUERIES_MIN_EXEC_TIME=100 SQL_LOG_OVERRIDE=false SQL_LOG_DIRECTORY=logs/sql SQL_CONVERT_TIME_TO_SECONDS=false SQL_LOG_SEPARATE_ARTISAN=falseand adjust values to your needs. If you have also .env.sampleit's also recommended to add those entries also in.env.samplefile just to make sure everyone know about those env variables. Be aware thatSQL_LOG_DIRECTORYis directory inside storage directory.
- 
Make sure directory specified in .envfile exists in storage path and you have valid file permissions to create and modify files in this directory