laravel-log日志分文件存储

淳于凯
2023-12-01

1.打开config文件夹的logging.php 文件,日志配置文件

2.在channels 数组中自定义一个事件驱动

'request_response' => [
            'driver' => 'daily',
            'path' => storage_path('logs/request_response.log'),
            'level' =>  env('APP_LOG_LEVEL', 'debug'),
        ],

3.在需要写日志的位置直接 \Illuminate\Support\Facades\Log::channel("request_response")->info("测试");

channel方法中传入要生成的文件驱动就可以了。

 类似资料: