PHPackages                             leon19910505/laralog - 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. leon19910505/laralog

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

leon19910505/laralog
====================

A middleware which could collect the log with json format of laravel application, including everyone request information。It's very friendly to harvest of filebeat

v1.1.5(5y ago)0154MITPHPPHP &gt;=7

Since Feb 26Pushed 5y agoCompare

[ Source](https://github.com/leon19910505/laralog)[ Packagist](https://packagist.org/packages/leon19910505/laralog)[ RSS](/packages/leon19910505-laralog/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (6)Dependencies (6)Versions (22)Used By (0)

Laralog
=======

[](#laralog)

功能
--

[](#功能)

- 提供 Laravel Http 中间件，捕捉 Http 请求生命周期内的必要信息
- Http 生命周期信息以 `JSON` 格式记录到日志文件中
- 提供了日志 `JSON` 化格式组件，可以无缝使用 `Filebeat` 采集日志到 `ES` 中，避免做格式优化
- 提供了过滤请求中敏感信息的配置，可以过滤到请求参数中的敏感信息，例如，密码等

安装
--

[](#安装)

1. 方式一

    - 添加 `Leon19910505/laralog` 包声明到工程项目的 `composer.json` 文件中
    - 使用 `composer install` 命令安装
2. 方式二

    - 使用如下命令直接安装依赖 ```
        $ composer require Leon19910505/laralog
        ```
3. 配置文件发布

    - 在项目目录下面运行如下命令，发布 `config` 资源文件 ```
        php artisan vendor:publish --provider="Leon19910505\Laralog\ServiceProvider"
        ```

配置
--

[](#配置)

### 配置 `Laravel` `Http` 中间件

[](#配置-laravel-http-中间件)

- 在 `app\Http\Kernel.php` 文件中，找到 `protected $middleware` 属性，添加如下声明。 ```
    $middleware = [
        ...
        \Leon19910505\Laralog\Http\Middleware\CaptureRequestLifecycle::class,
    ];
    ```

### 配置写日志组件

[](#配置写日志组件)

- 在 `.env` 配置中设置laralog专用的log channel `LOG_API`

    ```
    LOG_API=api
    ```
- 在 `config/logging.php` 中，设置laralog日志频道 `channel` 为 `api` 的日志组件，添加如下配置声明

    ```
    'api' => [
         // Monolog 提供的 driver,保留不变
        'driver' => 'daily',
        // channel 名称，要与数组键名保持一致
        'name'   => 'daily',
        // 日志存储路径，及日志文件命名
        'path'   => env('DAILY_LARALOG_STORAGE_PATH', storage_path('logs/api.log')),
        // 指定使用的日志格式化组件类
        'tap'    => [\Leon19910505\Laralog\Formatter\LaralogFormatter::class],
        'level'  => 'info',
        // 日志文件保留天数
        'days'   => 7,
        // 在写日志文件前获得锁，避免并发写入造成的争抢，写错行
        'locking'=> true,
    ],
    ```
- 配置过滤敏感信息的键值，如需新增过滤的敏感信息，在 `config/laralog.php` 中 `except` 键对应的数组中，增加待过滤的请求参数键值

    ```
    return [
        'except' => [
            'password',
            'password_information',
            'password_confirm',
            'something_to_except',
        ],
    ];
    ```
- 配置过滤敏感信息的键值，如需新增过滤的敏感信息，在 `config/laralog.php` 中 `except` 键对应的数组中，增加待过滤的请求参数键值

    ```
    return [
    //except 是过滤request参数里不需要的字段
    'except'  => [
        'password',
        'password_information',
        'password_confirm',
    ],
    //exclude 是过滤返回结构里不要的字段
    'exclude' => [
        'os',
        'performance',
        'msg',
        'response',
        'extra',
        'headers',
        'hostname',
        'version',
        'platform',
        'end',
        'start',
        'tag',
    ],
    // extra 是添加额外的字段（业务定制），这里是写入了token的用户信息
    'extra'   => [
        'auth-student' => function () {
            return auth()->user()->id ?? '';
        },
        'auth-teacher' => function () {
            return auth('teacher')->user()->id ?? '';
        },
    ],

    ];
    ```
- 配置日志存储路径，在 `.env` 文件中新增配置 `DAILY_LARALOG_STRORAGE_PATH=/path/to/laralog`

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~17 days

Recently: every ~37 days

Total

20

Last Release

1948d ago

Major Versions

v0.4.0 → v1.0.02020-03-02

### Community

Maintainers

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

---

Top Contributors

[![shallowman](https://avatars.githubusercontent.com/u/46313752?v=4)](https://github.com/shallowman "shallowman (3 commits)")[![leon19910505](https://avatars.githubusercontent.com/u/26701373?v=4)](https://github.com/leon19910505 "leon19910505 (1 commits)")

---

Tags

logjsonlaravelfilebeat

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/leon19910505-laralog/health.svg)

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

###  Alternatives

[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[jackiedo/log-reader

An easy log reader and management tool for Laravel

151376.5k4](/packages/jackiedo-log-reader)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[hryha/laravel-request-logger

A Laravel package to log requests and responses

102.2k](/packages/hryha-laravel-request-logger)

PHPackages © 2026

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