Created
November 26, 2018 18:36
-
-
Save ryantxr/89d8f65b1d2d31b8c2e95a608ef3fdaf to your computer and use it in GitHub Desktop.
Capture ALL SQL to a separate sql.log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Capture ALL SQL to a separate sql.log | |
// In config/logging.php add the following to the channel list | |
'sql' => [ | |
'driver' => 'single', | |
'path' => storage_path('logs/sql.log'), | |
'level' => 'debug', | |
], | |
// In app/Providers/AppServiceProvider.php add the following to the boot() method. | |
\DB::listen( | |
function($sql) { | |
\Illuminate\Support\Facades\Log::channel('sql')->debug('sql = '.var_export($sql->sql, true)); | |
\Illuminate\Support\Facades\Log::channel('sql')->debug('bindings = '.var_export($sql->bindings, true)); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment