Laravel-mongodb: Enable logging of executed queries

Created on 31 Jan 2014  Â·  3Comments  Â·  Source: jenssegers/laravel-mongodb

Any way to make MongoDB queries show up in \DB::getQueryLog()? It currently only logs SQL queries.

Most helpful comment

before query execute
DB::connection( 'mongodb' )->enableQueryLog();

after query
dd(DB::connection('mongodb')->getQueryLog());

you will get the array containing the query.

All 3 comments

DB::getQueryLog() will return the logs of the default connection. You need to specify your mongodb connection like this: DB::connection('mongodb')>getQueryLog()

Excellent! If everything would be so easy… :) Thanks!

before query execute
DB::connection( 'mongodb' )->enableQueryLog();

after query
dd(DB::connection('mongodb')->getQueryLog());

you will get the array containing the query.

Was this page helpful?
0 / 5 - 0 ratings