Skip to content

Swoft的日志FileHandler,支持最大日志文件限制

License

Notifications You must be signed in to change notification settings

anhoder/swoft-log-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swoft-log-handler

Swoft2的日志没有文件数量限制,会导致服务器的日志越积越多

该项目将Monolog中RotatingFileHandler的实现逻辑搬过来,同时继承Swoft2的FileHandler类。

每次生成日志文件时,都会检查相应的日志文件数量,并删除最老的日志。

使用

composer require anhoder/swoft-log-handler

app/bean.php下使用:

'testHandler'   => [
    'class'     => Anhoder\Swoft\Log\RotatingFileHandler::class,
    'logFile'   => '@runtime/logs/test/test-%d{Y-m-d}.log',
    'levels'    => 'notice,info,debug,trace,error,warning',
    'formatter' => bean('lineFormatter'),
    'maxFiles'  => 3,
    'checkLogInterval' => RotatingFileHandler::INTERVAL_DAY,
],

About

Swoft的日志FileHandler,支持最大日志文件限制

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages