在AppServiceProvider.php中的boot方法中添加如下代碼 即可
public function boot()
{
DB::listen(function($query) {
$tmp = str_replace('?', '"'.'%s'.'"', $query->sql);
$tmp = vsprintf($tmp, $query->bindings);
$tmp = str_replace("\\","",$tmp);
Log::info($tmp."\n\n\t");
});
}
執(zhí)行與數(shù)據(jù)庫(kù)相關(guān)的操作會(huì)在 storage\logs\laravel.log 文件中看到記錄執(zhí)行的sql語(yǔ)句