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

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

silverd/laravel-sql-logger
==========================

Log SQL queries in Laravel/Lumen framework

v2.2.5(6y ago)05.7kMITPHP

Since Feb 16Pushed 5y agoCompare

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

READMEChangelogDependencies (10)Versions (20)Used By (0)

Laravel SQL Logger
------------------

[](#laravel-sql-logger)

[![Packagist](https://camo.githubusercontent.com/154fe4312670e8cde256f74de7a4c4f751cedcd93f9ca95e69e508f6cba9bb78/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6e616269616c656b2f6c61726176656c2d73716c2d6c6f676765722e737667)](https://packagist.org/packages/mnabialek/laravel-sql-logger)[![Support via Paypal](https://camo.githubusercontent.com/fff91480d671fcfcf2b76a4125e320ca9c517e1ed195dd21fea653f7f253d9c7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742532307669612d70617970616c2d627269676874677265656e2e737667)](https://www.paypal.me/mnabialek/5usd)[![Build Status](https://camo.githubusercontent.com/3d1487e508652256d0d9d238a9d9fa390caa6f1d5e78636d9eb9af744d34da46/68747470733a2f2f7472617669732d63692e6f72672f6d6e616269616c656b2f6c61726176656c2d73716c2d6c6f676765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mnabialek/laravel-sql-logger)[![Coverage Status](https://camo.githubusercontent.com/1f9b9f899e3328d225d601e60c0f2810a9d2f479d7e589fb7d05117fce63c457/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d6e616269616c656b2f6c61726176656c2d73716c2d6c6f676765722f62616467652e737667)](https://coveralls.io/github/mnabialek/laravel-sql-logger)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b56d98f4cbd4dfaf313201e0b07030aafe28e6b66b71080ebccf2a5667f2b6fe/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6e616269616c656b2f6c61726176656c2d73716c2d6c6f676765722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mnabialek/laravel-sql-logger/)

This module allows you to log SQL queries (and slow SQL queries) to log file in Laravel/Lumen framework. It's useful mainly when developing your application to verify whether your queries are valid and to make sure your application doesn't run too many or too slow database queries.

### Support

[](#support)

Using this package is free of charge, however to keep it up-to-date and add new features small money support is appreciated. **Suggested amount is 5$ per project where you use this package but any amount will help further development of this package.**[![Support via Paypal](https://camo.githubusercontent.com/fff91480d671fcfcf2b76a4125e320ca9c517e1ed195dd21fea653f7f253d9c7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f737570706f72742532307669612d70617970616c2d627269676874677265656e2e737667)](https://www.paypal.me/mnabialek/5usd) (you are free to change amount on Paypal page)

### Installation

[](#installation)

1. Run

    ```
    composer require mnabialek/laravel-sql-logger --dev
    ```

    in console to install this module (Notice `--dev` flag - it's recommended to use this package only for development).
2. If you use Laravel &lt; 5.5 open `config/app.php` and in `providers` section add:

    ```
    Mnabialek\LaravelSqlLogger\Providers\ServiceProvider::class,
    ```

    Laravel 5.5 uses Package Auto-Discovery and it will automatically load this service provider so you don't need to add anything into above file.

    If you are using Lumen open `bootstrap/app.php` and add:

    ```
    $app->register(Mnabialek\LaravelSqlLogger\Providers\ServiceProvider::class);
    ```
3. If you use Laravel &lt; 5.5 run:

    ```
    php artisan vendor:publish --provider="Mnabialek\LaravelSqlLogger\Providers\ServiceProvider"
    ```

    in your console to publish default configuration files.

    If you are using Laravel 5.5 run:

    ```
    php artisan vendor:publish
    ```

    and choose the number matching `"Mnabialek\LaravelSqlLogger\Providers\ServiceProvider"` provider.

    By default you should not edit published file because all the settings are loaded from `.env` file by default.

    For Lumen you should skip this step.
4. In your .env file add the following entries:

    ```
    SQL_LOGGER_DIRECTORY="logs/sql"
    SQL_LOGGER_USE_SECONDS=false
    SQL_LOGGER_CONSOLE_SUFFIX=
    SQL_LOGGER_LOG_EXTENSION=".sql"
    SQL_LOGGER_ALL_QUERIES_ENABLED=true
    SQL_LOGGER_ALL_QUERIES_OVERRIDE=false
    SQL_LOGGER_ALL_QUERIES_PATTERN="#.*#i"
    SQL_LOGGER_ALL_QUERIES_FILE_NAME="[Y-m-d]-log"
    SQL_LOGGER_SLOW_QUERIES_ENABLED=true
    SQL_LOGGER_SLOW_QUERIES_MIN_EXEC_TIME=100
    SQL_LOGGER_SLOW_QUERIES_PATTERN="#.*#i"
    SQL_LOGGER_SLOW_QUERIES_FILE_NAME="[Y-m-d]-slow-log"
    SQL_LOGGER_FORMAT_NEW_LINES_TO_SPACES=false
    SQL_LOGGER_FORMAT_ENTRY_FORMAT="/* [origin]\\n   Query [query_nr] - [datetime] [[query_time]] */\\n[query]\\n[separator]\\n"

    ```

    and adjust values to your needs. You can skip variables for which you want to use default values.

    If you have also `.env.sample` it's also recommended to add those entries also in `.env.sample` file just to make sure everyone know about those env variables. Be aware that `SQL_LOGGER_DIRECTORY` is directory inside storage directory. If you want you can change it editing `config/sql_logger.php` file.

    To find out more about those setting please take a look at [Configuration file](publish/config/sql_logger.php)
5. Make sure directory specified in `.env` file exists in storage path and you have valid file permissions to create and modify files in this directory (If it does not exist this package will automatically create it when needed but it's recommended to create it manually with valid file permissions)
6. Make sure on live server you will set logging SQL queries to false in your `.env` file. This package is recommended to be used only for development to not impact production application performance.

### Upgrading from 1.\*

[](#upgrading-from-1)

When upgrading from `1.*` version you should remove current `sql_logger.php` config file and replace this with new one (see installation step). You should also use new variables in `.env` file (old won't be used).

### Authors

[](#authors)

Author of this awesome package is **[Marcin Nabiałek](http://marcin.nabialek.org/en/)** and [Contributors](https://github.com/mnabialek/laravel-sql-logger/graphs/contributors)

### Changes

[](#changes)

All changes are listed in [Changelog](CHANGELOG.md)

### License

[](#license)

This package is licenced under the [MIT license](LICENSE) however [Support](#support) is more than welcome.

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 98% 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 ~88 days

Recently: every ~82 days

Total

18

Last Release

2238d ago

Major Versions

1.0.x-dev → v2.02018-02-11

### Community

Maintainers

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

---

Top Contributors

[![mnabialek](https://avatars.githubusercontent.com/u/7656807?v=4)](https://github.com/mnabialek "mnabialek (96 commits)")[![silverd](https://avatars.githubusercontent.com/u/1514608?v=4)](https://github.com/silverd "silverd (1 commits)")[![yhbyun](https://avatars.githubusercontent.com/u/946080?v=4)](https://github.com/yhbyun "yhbyun (1 commits)")

---

Tags

loglaravellumensqlloggersql logsql loggerlog sql querieslog sql

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[mnabialek/laravel-sql-logger

Log SQL queries in Laravel/Lumen framework

158796.3k2](/packages/mnabialek-laravel-sql-logger)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[altek/accountant

The auditing &amp; accountability package for Laravel's Eloquent ORM.

92954.3k4](/packages/altek-accountant)[klaravel/db-logger

Laravel database/sql queries logger.

132.4k](/packages/klaravel-db-logger)

PHPackages © 2026

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