PHPackages                             yzh52521/think-log-driver - 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. yzh52521/think-log-driver

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

yzh52521/think-log-driver
=========================

require think-log-driver

v1.0.4(2y ago)7409[1 issues](https://github.com/yzh52521/think-log-driver/issues)MITPHPPHP &gt;=7.1.0

Since Nov 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yzh52521/think-log-driver)[ Packagist](https://packagist.org/packages/yzh52521/think-log-driver)[ RSS](/packages/yzh52521-think-log-driver/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

think-log-driver
================

[](#think-log-driver)

think-log-driver

依赖
--

[](#依赖)

适用于`thinkphp6.x,thinkphp8.x`php: &gt;=7.1

安装
--

[](#安装)

1. 安装`think-log-driver`

```
composer require yzh52521/think-log-driver
```

使用
--

[](#使用)

1. 更改配置
    在`config/log.php` 中的配置修改

```
// 日志记录方式
// 日志通道列表

    'channels'     => [
        'file'=>[],
        'database' => [
            // 日志记录方式
            'type'           => 'Database',
            // 大于0.05秒的sql将被记录
            'slow_sql_time'  => 0.5,
            // 记录日志的数据库配置，即在database.php中的driver
            // 如果设置该值为'default'，则使用系统数据库的实例
            'db_connect'     => 'default', //mongodb
            // 记录慢日志查询的数据表名
            'db_table'       => 'log_sql',
            // 忽略的操作，在以下数据中的操作不会被记录
            'action_filters' => [
                // 'index/Index/lst'
            ],
            // 日志保存目录
            'path'           => '',
            // 单文件日志写入
            'single'         => false,
            // 独立日志级别
            'apart_level'    => [],
            // 最大日志文件数量
            'max_files'      => 0,
            // 使用JSON格式记录
            'json'           => false,
            // 日志处理
            'processor'      => null,
            // 关闭通道日志写入
            'close'          => false,
            // 日志输出格式化
            'format'         => '[%s][%s] %s',
            // 是否实时写入
            'realtime_write' => false,
        ],
],
```

2. 创建数据库
    用于记录日志的mysql数据表,如果使用mongodb则无需创建

```
CREATE TABLE `th_log_sql` (
	`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`host` CHAR(200) NOT NULL DEFAULT '' COMMENT '请求的Host',
	`uri` CHAR(200) NOT NULL DEFAULT COMMENT '请求的URL',
	`ip` CHAR(50) NOT NULL DEFAULT '' COMMENT 'IP',
	`method` CHAR(50) NOT NULL DEFAULT '' COMMENT '提交方式',
	`app` CHAR(30) NOT NULL DEFAULT '' COMMENT '应用',
	`controller` CHAR(30) NOT NULL DEFAULT '' COMMENT '控制器',
	`action` CHAR(50) NOT NULL DEFAULT '' COMMENT '方法',
	`create_time` INT(11) NOT NULL DEFAULT '0',
	`create_date` DATETIME NULL DEFAULT NULL,
	`runtime` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000',
	`sql_list` TEXT NULL,
	`param` TEXT NULL,
	PRIMARY KEY (`id`),
	INDEX `runtime` (`runtime`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=1
;
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~241 days

Total

5

Last Release

1035d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/052aa4acd90ad5d672ae5abe8d27d1f576f9c07e1967e2f6bced03b84079310f?d=identicon)[yuanzhihai](/maintainers/yuanzhihai)

---

Top Contributors

[![yuanzhihai](https://avatars.githubusercontent.com/u/15060466?v=4)](https://github.com/yuanzhihai "yuanzhihai (18 commits)")

### Embed Badge

![Health badge](/badges/yzh52521-think-log-driver/health.svg)

```
[![Health](https://phpackages.com/badges/yzh52521-think-log-driver/health.svg)](https://phpackages.com/packages/yzh52521-think-log-driver)
```

###  Alternatives

[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[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)[open-telemetry/api

API for OpenTelemetry PHP.

1833.0M214](/packages/open-telemetry-api)[codemix/yii2-streamlog

A Yii 2 log target for streams in URL format

531.4M6](/packages/codemix-yii2-streamlog)

PHPackages © 2026

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