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(10mo ago)071MITPHPPHP ^8.0

Since Aug 28Pushed 3mo 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 today

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

33

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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

309d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44649700?v=4)[Ataul Galib](/maintainers/ataulgalib)[@ataulgalib](https://github.com/ataulgalib)

![](https://avatars.githubusercontent.com/u/228916285?v=4)[brrittoo](/maintainers/brrittoo)[@brrittoo](https://github.com/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

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.6k29.9M145](/packages/laravel-cashier)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M131](/packages/laravel-pulse)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

492.8k](/packages/itpathsolutions-dbstan)

PHPackages © 2026

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