日志对于程序调试来说,至关重要
laravel日志通过保存在storage/logs/laravel.log中
我们可以通过设置将不同的信息保存到不同的日志文件中
通过在config/logging.php中设置
>'aaa' => [ 'driver' => 'daily',
'path' => storage_path('logs/aaa/aaa.log'),
'level' => 'debug',
'days' => 14,
],
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
],
在`controller`中使用
>\\Log::info('hello');
$array = ["username" => "test"];
\\Log::info($array);
\\Log::channel('aaa')->info('aaaaaa');
$msg = ["'msg" => "error"];
\\Log::channel('aaa')->error($msg);