PHPackages                             brrittoo/query-debug-tools - 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. brrittoo/query-debug-tools

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

brrittoo/query-debug-tools
==========================

Advanced Database Query Logging &amp; Performance Monitor

v1.0.0(8mo ago)071MITPHPPHP ^8.0

Since Aug 28Pushed 1mo agoCompare

[ Source](https://github.com/brrittoo/query-debug-tools)[ Packagist](https://packagist.org/packages/brrittoo/query-debug-tools)[ RSS](/packages/brrittoo-query-debug-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (10)Versions (2)Used By (0)

Query Logger for Laravel
========================

[](#query-logger-for-laravel)

[![Latest Version](https://camo.githubusercontent.com/31365190795cf6d71b91b621315838cd8a2c25d52b34c76b266126ffc0c10c5e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6272726974746f6f2f71756572792d64656275672d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brrittoo/query-debug-tools)[![Total Downloads](https://camo.githubusercontent.com/e4fc70f29f25badffa017e11df46ec8e67e3bb2352d464729649aade1ebb834e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6272726974746f6f2f71756572792d64656275672d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brrittoo/query-debug-tools)[![License](https://camo.githubusercontent.com/0c3844f60ffa1bcf2333ec670531acb385e73e4c866e3ccbcd844347bdece23e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6272726974746f6f2f71756572792d64656275672d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brrittoo/query-debug-tools)

[![PHP Version Require](https://camo.githubusercontent.com/4189d4d5b9f70f5104c9aa1ec8c11de6b1d4172d779af88c81e04fe45f24421e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6272726974746f6f2f71756572792d64656275672d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/brrittoo/query-debug-tools)[![GitHub Issues](https://camo.githubusercontent.com/7e56cc8d1f69c8a866226ed11019768f50ad9566fd019b53675c4f81c382f190/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6272726974746f6f2f71756572792d64656275672d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://github.com/brrittoo/query-debug-tools/issues)[![GitHub Stars](https://camo.githubusercontent.com/c74bfaac7368905a19edeba52c09ac49e0766aa16051e4997eda8ea679326500/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6272726974746f6f2f71756572792d64656275672d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://github.com/brrittoo/query-debug-tools/stargazers)

Effortlessly log, monitor, and debug all database queries in your Laravel applications with detailed execution insights, source tracking, and customizable storag

---

Features
--------

[](#features)

- 📝 Comprehensive query logging with execution time tracking
- 🐌 Slow query detection with customizable threshold
- 📂 Configurable log storage and retention
- 🔍 Backtrace tracking to identify query origins
- 🖥️ Support for both web requests and console commands
- � Job/queue query logging support
- ⚙️ Flexible configuration options
- 📊 Multiple log formats (plain text or JSON)

---

Installation
------------

[](#installation)

Install via Composer:

```
composer require brrittoo/query-debug-tools
```

Publish the configuration file:

```
php artisan vendor:publish --provider="Brrittoo\QueryLogger\Providers\QueryLoggerServiceProvider"
--tag="query-logger-config"
```

---

Configuration
-------------

[](#configuration)

The published configuration is located at `config/querylogger.php`:

```
    return [
        /*
        |--------------------------------------------------------------------------
        | Query Logger Enable
        |--------------------------------------------------------------------------
        |
        | Enable or disable query logging globally.
        |
        */
        'enabled' => env('QUERY_LOGGER_ENABLED', true),

        	    /*
		|--------------------------------------------------------------------------
		| Query Logger Enable
		|--------------------------------------------------------------------------
		|
		| Enable or disable query logging globally.
		|
		*/
	    'enable_generate_multiple_files_in_same_file' => env('QUERY_LOGGER_MULTIPLE_FILES', true),

        /*
        |--------------------------------------------------------------------------
        | Log Retention Days
        |--------------------------------------------------------------------------
        |
        | Number of days to keep log files before automatic deletion.
        | Set to 0 to disable automatic cleanup.
        |
        */
        'retention_days' => env('QUERY_LOGGER_RETENTION_DAYS', 15),

        /*
        |--------------------------------------------------------------------------
        | Storage Path
        |--------------------------------------------------------------------------
        |
        | Location where query log files will be stored.
        |
        */
        'storage_path' => storage_path('logs/querylog'),

        /*
        |--------------------------------------------------------------------------
        | Slow Query Threshold
        |--------------------------------------------------------------------------
        |
        | Only log queries slower than this threshold (in milliseconds).
        | Set to 0 to log all queries.
        |
        */
        'slow_query_threshold' => env('QUERY_LOGGER_SLOW_QUERY_THRESHOLD', 0),

        /*
        |--------------------------------------------------------------------------
        | Log Format
        |--------------------------------------------------------------------------
        |
        | Format of the log files: 'plain' or 'json'.
        |
        */
        'log_format' => env('QUERY_LOGGER_FORMAT', 'plain'),

        /*
        |--------------------------------------------------------------------------
        | Middleware Configuration
        |--------------------------------------------------------------------------
        |
        | Settings for automatic middleware registration.
        |
        */
        'middleware' => [
            /*
            |----------------------------------------------------------------------
            | Auto-Registered Middleware Groups
            |----------------------------------------------------------------------
            |
            | Middleware groups where the query logger should be automatically
            | registered (e.g., 'web', 'api').
            |
            */
            'enable_groups' => [
                'web',
                'api'
            ],

            /*
            |----------------------------------------------------------------------
            | Middleware Alias
            |----------------------------------------------------------------------
            |
            | The alias to use when registering the middleware.
            |
            */
            'alias' => 'query.logger',

            /*
            |----------------------------------------------------------------------
            | Excluded Routes
            |----------------------------------------------------------------------
            |
            | Route names that should be excluded from logging.
            |
            */
            'exclude_routes' => [
                'login',
                'health-check',
                'horizon.*',
                'telescope',
                'debugbar.*'
            ],
        ],
        /*
        |--------------------------------------------------------------------------
        | Backtrace
        |--------------------------------------------------------------------------
        |
        | Whether to include the query origin backtrace.
        |
        */
        'log_backtrace' => env('QUERY_LOGGER_LOG_BACKTRACE', true),

        /*
        |--------------------------------------------------------------------------
        | Max Backtrace Depth
        |--------------------------------------------------------------------------
        |
        | Maximum number of backtrace frames to log.
        |
        */
        'backtrace_depth' => env('QUERY_LOGGER_BACKTRACE_DEPTH', 5),
    ];
```

---

Usage
-----

[](#usage)

Configuration
-------------

[](#configuration-1)

Set these in your `.env`:

```
| Variable                            | Default | Description                                                                            |
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------- |
| `QUERY_LOGGER_ENABLED`              | `true`  | Enable or disable query logging globally.                                              |
| `QUERY_LOGGER_MULTIPLE_FILES`       | `true`  | Generate multiple log files per day. Set `false` to append to a single daily log file. |
| `QUERY_LOGGER_RETENTION_DAYS`       | `15`    | Number of days to keep old logs; older logs will be deleted automatically.             |
| `QUERY_LOGGER_SLOW_QUERY_THRESHOLD` | `1000`  | Threshold in milliseconds to consider a query as slow.                                 |
| `QUERY_LOGGER_FORMAT`               | `plain` | Log format: `plain` or `json`.                                                         |
| `QUERY_LOGGER_LOG_BACKTRACE`        | `false` | Enable logging of backtrace for each query.                                            |
| `QUERY_LOGGER_BACKTRACE_DEPTH`      | `5`     | Depth of backtrace to log (only used if backtrace logging is enabled).                 |
```

### Middleware

[](#middleware)

Add `query.logger` middleware to your routes or groups if not using auto-registration:

```
Route::middleware(['query.logger'])->group(function () {
    Route::get('/', fn() => 'Hello World');
});
```

### Manual Logging

[](#manual-logging)

Enable query logging anywhere:

```
QueryLogger::generateQueryLog($file_name);
```

### Command Logging

[](#command-logging)

Enable query logging inside an Artisan command:

```
QueryLogger::enableForCommand($this->getName());
```

### Job Logging

[](#job-logging)

Enable query logging inside a queued job:

```
QueryLogger::enableForJob(get_class($this));
```

---

Log Format
----------

[](#log-format)

- `plain` — human-readable logs
- `json` — structured logs for programmatic analysis

---

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

[](#contributing)

1. Fork the repository
2. Create your feature branch: `git checkout -b feature/MyFeature`
3. Commit your changes: `git commit -m 'Add new feature'`
4. Push to the branch: `git push origin feature/MyFeature`
5. Submit a pull request

🔗 Repository Link:
--------------------------------------------------------------

[](#-repository-link-httpsgithubcomataulgalibquery-debug)

License
-------

[](#license)

This package is open-sourced under the [MIT license](LICENSE).

---

Author
------

[](#author)

**Ataul Galib**
Email:

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance77

Regular maintenance activity

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

263d ago

### Community

Maintainers

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

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

---

Top Contributors

[![ataulgalib](https://avatars.githubusercontent.com/u/44649700?v=4)](https://github.com/ataulgalib "ataulgalib (1 commits)")

---

Tags

laravelloggingdatabaseperformancedebuggingquery

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/brrittoo-query-debug-tools/health.svg)

```
[![Health](https://phpackages.com/badges/brrittoo-query-debug-tools/health.svg)](https://phpackages.com/packages/brrittoo-query-debug-tools)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[jerome/filterable

Streamline dynamic Eloquent query filtering with seamless API request integration and advanced caching strategies.

19226.1k](/packages/jerome-filterable)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[ntanduy/cloudflare-d1-database

Easy configuration and setup for D1 Database connections in Laravel.

215.4k](/packages/ntanduy-cloudflare-d1-database)

PHPackages © 2026

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