1、AppServiceProvider.php中
\DB::listen(function ($query){ $sql = $query->sql; $bindings = $query->bindings; $time = $query->time; if($time>10){ //when time > 10 print \Log::debug(var_export(compact([‘sql‘,‘bindings‘,‘time‘]),true)); } });
2、注意
var_export(compact([‘sql‘,‘bindings‘,‘time‘]))默认前台页面打印
var_export(compact([‘sql‘,‘bindings‘,‘time‘]),true)将会存储在storage\logs\laravel.log中
原文地址:https://www.cnblogs.com/onew/p/11707059.html
时间: 2024-10-10 06:22:34