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中

相关文章:

  • 2022-03-01
  • 2021-08-26
  • 2021-08-24
  • 2021-11-08
  • 2021-08-19
  • 2022-12-23
  • 2021-11-09
猜你喜欢
  • 2022-02-20
  • 2021-08-31
  • 2021-11-20
  • 2022-01-29
  • 2021-09-10
  • 2021-05-27
相关资源
相似解决方案