laravel5.5或laravel5.7版本自定义日志记录

laravel5.5自定义日志使用

在任意位置调用自定义日志前写入即可

$monolog = \Log::getMonolog();
$monolog->popHandler();
\Log::useFiles(storage_path(‘logs/test/test.log‘));
\Log::info(‘test‘);
laravel5.7自定义日志使用

在config文件夹下找到logging中找到

 

‘channels‘ => [
  ......
‘adminlog‘ => [
‘driver‘ => ‘daily‘,
‘path‘ => storage_path(‘logs/adminlog/adminlog.log‘),
‘level‘ => ‘debug‘,
‘days‘ => 14,
],


]
调用即可
Log::channel(‘adminlog‘)->info(‘adminlog ok‘);
搞定,收工!!!
相关文章
相关标签/搜索