PHPackages                             rstriquer/eloquent-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. [Database &amp; ORM](/categories/database)
4. /
5. rstriquer/eloquent-logger

ActiveLibrary[Database &amp; ORM](/categories/database)

rstriquer/eloquent-logger
=========================

Write SQL queries to a file into Laravel "storage/logs" directory.

1.0.0(3y ago)43.1k1[1 PRs](https://github.com/rstriquer/eloquent-logger/pulls)MITPHPPHP &gt;7.0

Since Apr 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rstriquer/eloquent-logger)[ Packagist](https://packagist.org/packages/rstriquer/eloquent-logger)[ Docs](https://github.com/rstriquer/eloquent-logger)[ RSS](/packages/rstriquer-eloquent-logger/feed)WikiDiscussions main Synced 1mo ago

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

Eloquent Logger
===============

[](#eloquent-logger)

A package to allow logging of all SQL queries executed by an application built in Laravel by the eloquent ORM component.

This package builds a Laravel provider inside "vendors" folder which attaches a listener to the Eloquent Console Manager that writes ane query to a log output.

As the package is in vendors and installed in the dev, the developer does not need to worry about adding or removing codes from providers, as recommended in some pages on the internet, thus facilitating his day-to-day bases;

**IMPORTANT**:

- This module is not recommended for production use. It was built only for DEVELOPMENT environment;
- Considering the package writes all queries, it is recommended to keep it turned off, even in a development environment, and turn it on only when performing query improvement work since it may consume a considerable amount of size on HDD when running uninterruptedly;
- In very extreme and specific cases, where you are writing very (very) large contents (such as longtext fields or similar) it is possible that there are situations in which the plugin results in recording failures, depending on the limitations of your operating system (in old windows versions depending on FAT32 it may limit the size of the output file to less then 4gb);
- By and large at the end the log file is not that big but there is no logrotate functionality set therefore I recommend you monitor the log file size and delete it whenever necessary;

Minimum Requirements
--------------------

[](#minimum-requirements)

This plugin was built when using Laravel version 8.0 and should work properly with any Laravel version after 8.

If you have the opportunity to successfully use this plugin in a previous laravel release please consider opening an [issue](https://github.com/rstriquer/eloquent-logger/issues)to report your experience.

If you have any problems with this plugin please report it by following the steps on "Contributing" below.

How to install
--------------

[](#how-to-install)

Just run the following:

```
composer require rstriquer/eloquent-logger --dev
```

If you want you can personalize the log filename by setting the environment variable `DB_LOGGER_FILE`. It works with `.end` file and the file must be placed at storage directory.

how to use the plugin
---------------------

[](#how-to-use-the-plugin)

Just set the environment variable `DB_LOGGER_ACTIVE` to true in your `.env` file and run the application. The file set on `DB_LOGGER_FILE`variable (which defaults to '/logs/query.log' located at the storage directory at your application root folder) should contain all the queries performed by that run sequentially.

To restrict the log file to the lasting 10 lines you can run the following sequence of commands:

```
tail -n 10 storage/logs/query.log > storage/logs/query.tmp && \
    cat storage/logs/query.tmp > storage/logs/query.log && \
    rm storage/logs/query.tmp
```

Contributing
------------

[](#contributing)

The code is located in the Git repository at [github](https://github.com/rstriquer/eloquent-logger). Contributions are most welcome by forking the repository and sending a pull request.

Discussions are done on [GitHub issue tracker](https://github.com/rstriquer/eloquent-logger/issues)

Always remember to check on lint and types before post code:

```
composer run test:lint
composer run test:types
```

PS: If necessary to fix lint you can just run `composer run lint` a couple of times till it passes green and it will fix itself automatically.

To test a specific change you may configure your composer.json file in your project like [described here](https://gist.github.com/rstriquer/541cf089ce51d3bcb9125af50ff68160)

How to unit-test
----------------

[](#how-to-unit-test)

This package make use of in memory sqlite to test its feature therefore be sure to have ext-sqlite installed on your system before running tests.

```
composer run test:unit
```

Code of Conduct
---------------

[](#code-of-conduct)

We follow and support the Laravel Code of Conduct and in order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).

Authors and License
-------------------

[](#authors-and-license)

This is an open source project by [@rstriquer](https://rstriquer.github.io/portfolio)and licensed under [MIT](https://github.com/rstriquer/eloquent-logger/blob/main/LICENSE)license.

rstriquer reserves the right to change the license in future releases without prior notification, but understand and agree that versions until such time remain under the MIT license as here described.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

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

Total

5

Last Release

1124d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/669705?v=4)[Ricardo Striquer Soares](/maintainers/rstriquer)[@rstriquer](https://github.com/rstriquer)

---

Top Contributors

[![rstriquer](https://avatars.githubusercontent.com/u/669705?v=4)](https://github.com/rstriquer "rstriquer (64 commits)")

---

Tags

eloquenteloquent-ormlaravelloggersqllaraveldeveloquentdebuggerloggerlaravel-dev

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rstriquer-eloquent-logger/health.svg)

```
[![Health](https://phpackages.com/badges/rstriquer-eloquent-logger/health.svg)](https://phpackages.com/packages/rstriquer-eloquent-logger)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11120.2M21](/packages/anourvalar-eloquent-serialize)[bavix/laravel-clickhouse

Eloquent model for ClickHouse

72214.1k2](/packages/bavix-laravel-clickhouse)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

823.1k](/packages/waad-laravel-model-metadata)[mozex/laravel-scout-bulk-actions

A Laravel Scout extension for bulk importing and flushing of all models.

1033.4k](/packages/mozex-laravel-scout-bulk-actions)

PHPackages © 2026

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