PHPackages                             vinlon/laravel-sql-logger - 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. vinlon/laravel-sql-logger

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

vinlon/laravel-sql-logger
=========================

Log Sql Queries in Laravel framework

0.2.0(5y ago)03362MITPHP

Since Nov 13Pushed 5y ago1 watchersCompare

[ Source](https://github.com/vinlon/laravel-sql-logger)[ Packagist](https://packagist.org/packages/vinlon/laravel-sql-logger)[ RSS](/packages/vinlon-laravel-sql-logger/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (9)Used By (2)

Laravel Sql Logger
==================

[](#laravel-sql-logger)

版本支持
====

[](#版本支持)

- laravel 6.\*
- laravel 7.\*

使用方法
====

[](#使用方法)

1. 引入 package

    ```
    composer require vinlon/laravel-sql-logger

    ```
2. 发布config文件 (Laravel 版本 &gt; 5.5)

    先执行如下命令

    ```
    php artisan vendor:publish

    ```

    然后选择 Provider: Vinlon\\Laravel\\SqlLogger\\SqlLoggerProvider 对应的序号

    在应用程序的config目录下，将生成sql-logger.php文件（注：一般情况下，此文件不需要做任何修改，配置的调整通过环境变量实现）
3. 默认配置

    安装完成后，默认同时开启All Query和Slow Query日志，使用logger中定义的默认channel. SQL执行时间超过 1 秒钟（1000ms） 会被定义为慢查询
4. 配置建议

    ```
    # ALL QUERY LOG 只在 debug 模式下开启
    SQL_LOGGER_ALL_QUERY_ENABLED="${APP_DEBUG}"

    # SLOW QUERY LOG 可以视情况而定，如果团队没有专门的DBA对数据库运行情况进行监控，可以考虑在生产环境开启
    SQL_LOGGER_SLOW_QUERY_ENABLED=true

    # 根据业务数据量及对SQL执行效率的敏感程度决定
    SQL_LOGGER_SLOW_QUERY_THRESHOLD=1000

    # 为 SQL 日志定义专门的 LOG CHANNEL
    SQL_LOGGER_ALL_QUERY_LOG_CHANNEL=sql-logger
    SQL_LOGGER_SLOW_QUERY_LOG_CHANNEL=slow-sql-logger

    ```

    Log Channel示例 (config/logging.php)

    ```
    'sql-logger' => [
        'driver' => 'daily',
        'path' => storage_path('logs/sql.log'),
        'level' => 'debug',
        'days' => 14,
    ]

    ```

TODO
====

[](#todo)

1. 单元测试
2. 更多Laravel版本的测试与支持

参考
==

[](#参考)

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

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

Recently: every ~54 days

Total

8

Last Release

1835d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/277ca050c3c4260b26cadec49dafbaa2ff68d1487901ee3be0f930ad890b4d1e?d=identicon)[vinlon](/maintainers/vinlon)

---

Top Contributors

[![vinlon](https://avatars.githubusercontent.com/u/3851841?v=4)](https://github.com/vinlon "vinlon (3 commits)")

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/vinlon-laravel-sql-logger/health.svg)

```
[![Health](https://phpackages.com/badges/vinlon-laravel-sql-logger/health.svg)](https://phpackages.com/packages/vinlon-laravel-sql-logger)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)[open-telemetry/opentelemetry-auto-laravel

OpenTelemetry auto-instrumentation for Laravel

592.7M9](/packages/open-telemetry-opentelemetry-auto-laravel)[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14845.8k1](/packages/guanguans-laravel-exception-notify)[nightowl/agent

NightOwl monitoring agent — collects telemetry from laravel/nightwatch and writes to PostgreSQL

771.7k](/packages/nightowl-agent)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)

PHPackages © 2026

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