We noticed you're using an ad blocker

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Laravel Query Log

world cup 2022


Get update standing EPL, UEFA, LaLiga and more

Get Now

During application query and speed optimization, we have to investigate how many queries are running for specific endpoint requests and what is the line number of that query and how much time does that query required for executing and more. In this scenario, the Laravel Query Log package make our life easier. Just install it and enable it from your env file and done! It will log all your laravel executed SQL queries, line number, total query, final SQL, SQL bindings and much more. Let's see how we can install and use it in your Laravel project.



  • Lightweight package and easy installation.
  • Shows total executed query, total time, endpoint, HTTP method.
  • Each executed query shows line number, bindings and final query that can be run through your SQL client.
  • Directly navigate to a specific file line number by clicking ctrl+file path.
  • Text log data format (default).
  • JSON log data format.


Sample Query Log

url         : http://example.test
method      : GET
total_query : 3
total_time  : 5.69

sl          : 1
query       : select * from `students` where `id` = ? and `name` = ?
bindings    : 6|Tomas
final_query : select * from `students` where `id` = 6 and `name` = 'Tomas'
time        : 4.38
file        : C:\www\example\app\Http\Controllers\SiteController.php:10
line        : 10

sl          : 2
query       : select * from `students` where `id` = ? and `phone` = ?
bindings    : 6|649-768-7305
final_query : select * from `students` where `id` = 6 and `phone` = '649-768-7305'
time        : 0.75
file        : C:\www\example\app\Http\Controllers\SiteController.php:11
line        : 11

sl          : 3
query       : select * from `students` where `id` = ?
bindings    : 6
final_query : select * from `students` where `id` = 6
time        : 0.56
file        : C:\www\example\app\Http\Controllers\SiteController.php:12
line        : 12



Installation is very simple. Just run this composer command via your command prompt.

composer require haruncpi/laravel-query-log



To enable the query log, put this in your .env file.


Now you will see each executed query log in the query.log file inside the storage directory. The default log format is text. You can set JSON data format by setting QUERY_LOG_FORMAT=json

Source code of Laravel Query Log in GitHub repository.


Share on

Related Post - Latest Post

Tinkerpad - A minimal Laravel code editor

Laravel Jetstream tutorial

Laravel User Activity

Laravel Breeze - Starting with Laravel has been easy!

Laravel API mailer

Laravel H package