Skip to content

Instantly share code, notes, and snippets.

@danielstgt
Created January 12, 2022 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielstgt/ff4d06caccab29e33027b6dc24c9fbf5 to your computer and use it in GitHub Desktop.
Save danielstgt/ff4d06caccab29e33027b6dc24c9fbf5 to your computer and use it in GitHub Desktop.
DB Query Logging with Laravel
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