PHPackages                             anhoder/swoft-log-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. anhoder/swoft-log-handler

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

anhoder/swoft-log-handler
=========================

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

0.1.1(5y ago)1149MITPHPPHP &gt;=7.1

Since Jan 6Pushed 5y ago1 watchersCompare

[ Source](https://github.com/anhoder/swoft-log-handler)[ Packagist](https://packagist.org/packages/anhoder/swoft-log-handler)[ RSS](/packages/anhoder-swoft-log-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

swoft-log-handler
-----------------

[](#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,
],
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1950d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/27605589?v=4)[anhoder](/maintainers/anhoder)[@anhoder](https://github.com/anhoder)

---

Top Contributors

[![anhoder](https://avatars.githubusercontent.com/u/27605589?v=4)](https://github.com/anhoder "anhoder (8 commits)")

---

Tags

logrotating-logswoft2

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anhoder-swoft-log-handler/health.svg)

```
[![Health](https://phpackages.com/badges/anhoder-swoft-log-handler/health.svg)](https://phpackages.com/packages/anhoder-swoft-log-handler)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
