只用在配置文件config\logging.php里加一个配置就可以了
'sql' => [
'driver' => 'daily',
'path' => storage_path('logs/sql/sql.log'),
'level' => 'debug',
'days' => 14,
],
调用的时候切一下
DB::listen(function ($query) {
Log::channel("sql")->info($query->sql."===".$query->time);
});