How Get Query Logs In Laravel

[Solved] How Get Query Logs In Laravel | Php - Code Explorer | yomemimo.com
Question : How to Log Query in Laravel

Answered by : indian-gooner

DB::enableQueryLog();
$arr_user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());

Source : https://artisansweb.net/how-to-log-query-in-laravel/ | Last Update : Wed, 06 May 20

Question : How to Log Query in Laravel

Answered by : amit-rajput

DB::enableQueryLog();
$user = DB::table('users')->select('name', 'email as user_email')->get();
dd(DB::getQueryLog());

Source : | Last Update : Thu, 14 Jan 21

Question : how get query logs in laravel

Answered by : shafeeque-ahmad

Method #1
instead of ->get use ->toSql() on query
$users = User::orderBy('name', 'asc')->toSql();
echo $users;
// Outputs the string:
'select * from `users` order by `name` asc'
Method # 2
DB::enableQueryLog();
// and then you can get query log
dd(DB::getQueryLog());

Source : https://stackoverflow.com/questions/27753868/how-to-get-the-query-executed-in-laravel-5-dbgetquerylog-returning-empty-ar | Last Update : Tue, 07 Dec 21

Question : query log laravel

Answered by : kriss-sachintha

import DB with this line first,
use Illuminate\Support\Facades\DB;

Source : | Last Update : Wed, 14 Sep 22

Question : query log laravel

Answered by : kriss-sachintha

check whethe the serviceprovider is added in the providers array in config/app.php if no then check whether the service provider class is the correct location and include the serivce provider in the providers array in config.app.php 

Source : https://stackoverflow.com/questions/40695978/how-to-fix-service-provider-class-not-found-when-using-repository | Last Update : Wed, 14 Sep 22

Answers related to how get query logs in laravel

Code Explorer Popular Question For Php