PHPackages                             leite/log - 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. leite/log

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

leite/log
=========

日志记录

00PHP

Since Feb 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/yshshenai/log)[ Packagist](https://packagist.org/packages/leite/log)[ RSS](/packages/leite-log/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

leitelog
========

[](#leitelog)

组件引入
----

[](#组件引入)

leite/log 是Thinkphp日志组件，组件发布在公司的私服平台， 在项目composer.json配置好私服平台地址后， 执行以下命令，可以将组件引入到项目中

```
composer require leite/log
# 优化加载
composer du -o
```

变更日志驱动
------

[](#变更日志驱动)

在 config/log.php 中添加以下配置

```
'channels'     => [
    .....

    // 雷特日志组键
    'leiteLog' => [
        'type'           => \Leite\Log\LogHandler::class,
    ]
]
```

日志记录方法
------

[](#日志记录方法)

日志记录方法和原生的日志组件一样，需要注意的点是我们尽量按照规范化的方式记录日志

```
Log::info([
            'logTag' => '日志标记',
            'request' => '请求数据',
            'response' => '响应数据',
        ]);
```

日志记录规范
------

[](#日志记录规范)

为了规范化日志的格式，我们在记录日志时应该按照以下格式记录

日志内容应包含以下字段

字段是否必填类型字段说明logTag是字符串标记这个日志的类型，可以方便快速定位日志request否数组用于记录输入的数据（例如： 请求内容等）response否数组用于记录输出的内容和我们希望记录的日志内容日志组件 .env 配置说明
--------------

[](#日志组件-env-配置说明)

日志的 env 在 leiteLog 下

选项值说明log\_app\_name记录到日志系统的APP名称, 未设置则默认为应用名称log\_file\_path本地日志文件存储路径， 未设置则默认为应用的 runtime/log 目录下log\_channel日志记录驱动 （database ｜ rabbitmq ） 默认值：databaselog\_level日志记录最小等级log\_table\_name数据库日志记录的表名， 未设置则默认值未 前缀\_log日志输出到数据库说明
----------

[](#日志输出到数据库说明)

为了规范化日志记录， 当日志缺少logTag标记时日志不会记录到数据库中

php 版本需要大于等于7.3
---------------

[](#php-版本需要大于等于73)

注：如果线上存在其他 php 脚本，请确保执行该脚本的用户和 php-fpm 的用户保持一致，否则可能会造成因为权限不一致而无法写入的错误
---------------------------------------------------------------------

[](#注如果线上存在其他-php-脚本请确保执行该脚本的用户和-php-fpm-的用户保持一致否则可能会造成因为权限不一致而无法写入的错误)

使用说明
----

[](#使用说明)

该日志组件可以直接替换Thinkphp的日志组件，记录日志的方法和原生的日志组件一样， 支持无缝衔接

附录：
---

[](#附录)

### DB日志表结构

[](#db日志表结构)

```
-- auto-generated definition
create table 表前缀_log
(
    id           bigint auto_increment comment '主键'
        primary key,
    level        varchar(10)  default ''                not null comment '日志级别(trace, debug, info, warn, error)',
    log_tag      varchar(255) default ''                not null comment '日志标签',
    log          text                                   null comment '日志完整信息',
    trace_id     char(32)     default ''                not null comment '全链路TraceId',
    pid          int          default 0                 not null comment '进程id',
    timestamp    datetime                               null comment '日志触发时间',
    created_time datetime     default CURRENT_TIMESTAMP not null comment '创建时间'
)
    comment '日志记录';

create index idx_log_tag
    on oms_log (log_tag);

create index idx_trace_id
    on oms_log (trace_id);
```

全局监控的LogTag
-----------

[](#全局监控的logtag)

logTag说明内容request\_log.请求接口路径记录所有的接口请求日志request 请求参数 response为响应内容 costTime 接口处理耗时 method 请求方式 memory\_usage 内存消耗

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b747bc75b4aa0f2b5d7c5d501937fc946cd7ca22780e8359962cf14e92edfdf9?d=identicon)[yshshenai](/maintainers/yshshenai)

### Embed Badge

![Health badge](/badges/leite-log/health.svg)

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

###  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)[ekino/newrelic-bundle

Integrate New Relic into Symfony2

28111.2M8](/packages/ekino-newrelic-bundle)

PHPackages © 2026

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