jmhc/laravel-log is a Laravel package for laravel log..
It currently has 0 GitHub stars and 34 downloads on Packagist (latest version v8.0.1).
Install it with composer require jmhc/laravel-log.
Discover more Laravel packages by jmhc
or browse all Laravel packages to compare alternatives.
Last updated
环境变量值参考:env
使用以下命令安装:
$ composer require jmhc/laravel-log
JMHC_LOG_DEBUG=false 时 debug 级别日志不写入(默认为 fasle)dir(string $dir) 设置日志保存路径,相对于 storage/logsname(string $dir) 设置日志名称(默认为 laravel.log)withDateToDir(bool $isBefore = true, string $format = 'Ymd') 给路径添加日期withDateToName(bool $isBefore = true, string $format = 'Ymd') 给名称添加日期withRequestInfo(bool $with = true) 日志添加请求消息withMessageLineBreak(bool $with = true) 日志添加消息换行throwable(Throwable $e, array $context = []) 记录异常日志业务代码:
use Jmhc\Log\Log;
// 添加各个级别日志
// emergency、alert、 critical、 error、 warning、 notice、 info 和 debug
Log::info('This is info log');
// 添加指定路径
// app/storage/logs/d/laravel.log
Log::dir('d')
->info('This is info log');
// app/storage/logs/20200101/d/laravel.log
Log::dir('d')
->withDateToDir()
->info('This is info log');
// 添加指定名称路径
// app/storage/logs/d/i.log
Log::dir('d')
->name('i')
->info('This is info log');
// app/storage/logs/d/20200101-i.log
Log::dir('d')
->name('i')
->withDateToName()
->info('This is info log');