technoknol / log-my-queries
Laravel middleware to Log all queries being fired to Laravel log file. Uses Laravel's default monolog library and sniffs Eloquent queries
Installs: 609
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:plugin
Requires
- php: ^5.5.9 || ^7.0
This package is not auto-updated.
Last update: 2021-06-01 17:46:23 UTC
README
Laravel middleware to Log all queries being fired to Laravel log file. Uses Laravel's default monolog library and sniffs Eloquent queries
Install via composer
Run the following command to pull in the latest version:
composer require technoknol/log-my-queries
Add middleware
Add the middleware to the $middleware
array in the app/Http/Kernel.php
file as follows:
protected $middleware = [
...
\technoknol\LogMyQueries\LogMyQueriesMiddleware::class
];
If you have APP_DEBUG=true
and APP_LOG_LEVEL=debug
you'll see all executed queries are being added in log file at storage/logs/laravel.log
.
Example from laravel.log
[2018-01-02 09:20:26] local.DEBUG: LogMyQueries_STARTED
[2018-01-02 09:20:26] local.DEBUG: select * from "users" where "id" = 102 limit 1
[2018-01-02 09:20:26] local.DEBUG: LogMyQueries_STARTED
[2018-01-02 09:20:28] local.DEBUG: LogMyQueries_STARTED
[2018-01-02 09:20:28] local.DEBUG: select * from "users" where "id" = 102 limit 1
[2018-01-02 09:20:28] local.DEBUG: update "users" set "remember_token" = "1q8nbeh2k6MkneGz31DCJaVJd4H1cBroBBLs6yCfQUoGQaFBSuVLFt7Br7mr" where "id" = "102"
That's it. You're done.