Created
November 29, 2025 16:40
-
-
Save InnaTarasyan/3c6c38f49b8b582c03e75cbc77039619 to your computer and use it in GitHub Desktop.
Log Only Slow Queries (>100ms)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // app/Providers/AppServiceProvider.php | |
| use Illuminate\Support\Facades\DB; | |
| use Illuminate\Support\Facades\Log; | |
| public function boot() | |
| { | |
| DB::listen(function ($query) { | |
| if ($query->time > 100) { | |
| Log::warning('Slow Query: '.$query->sql, [ | |
| 'time_ms' => $query->time, | |
| 'bindings' => $query->bindings, | |
| ]); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment