laravel中日志设置

日志对于程序调试来说,至关重要

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);

    A+
发布日期:2020年11月03日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: