How to View QueryLog in Laravel

The QueryLog is disabled as default in Laravel 5. To enable QueryLog you have to call

DB::enableQueryLog();

Another way is to register an event listener.

DB::listen(

    function ($sql, $bindings, $time) {

        //  $sql - select * from `ncv_users` where `ncv_users`.`id` = ? limit 1

        //  $bindings - [5]

        //  $time(in milliseconds) - 0.38 

    }

);  

If your project has multiple database connections you have to specify the connection .

DB::connection('db_connection1')->enableQueryLog();

To view the QueryLog for that connection,

print_r(

   DB::connection('db_connection1')->getQueryLog()

);