I think the answer located in this article: https://arjunphp.com/laravel-5-5-log-eloquent-queries/
is fast and simple to achieve query logging.
You just have to add to the AppServiceProvider
in the boot
method a callback to listen to DB queries:
namespace App\Providers;
use DB;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
DB::listen(function($query) {
logger()->info($query->sql . print_r($query->bindings, true));
});
}
}