Created
January 12, 2022 08:43
-
-
Save danielstgt/ff4d06caccab29e33027b6dc24c9fbf5 to your computer and use it in GitHub Desktop.
DB Query Logging with Laravel
This file contains 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
namespace App\Providers; | |
use DB; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
DB::listen(function($query) { | |
logger()->info( | |
$query->sql, | |
$query->bindings, | |
$query->time | |
); | |
}); | |
} | |
// | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment