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

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

hesamrad/laravel-sql-logger
===========================

A lightweight package to log SQL queries in your Laravel application

v1.0.0(3mo ago)11MITPHPPHP ^8.1

Since Feb 5Pushed 3mo agoCompare

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

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

Laravel SQL Logger
==================

[](#laravel-sql-logger)

A lightweight package to log SQL queries in your Laravel application; perfect for debugging and performance analysis during development.

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

[](#installation)

Install via Composer:

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

The package will automatically register its service provider.

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

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="HesamRad\LaravelSqlLogger\LaravelSqlLoggerServiceProvider"
```

This will create `config/sql-logger.php` config file.

Usage
-----

[](#usage)

Once installed and configured, SQL logging will automatically start based on your configuration.

### Viewing Logs

[](#viewing-logs)

SQL queries are logged to `storage/logs/sql.log` by default. You can view them with:

```
# Tail the log file (Linux/Mac)
tail -f storage/logs/sql.log

# View entire log
cat storage/logs/sql.log
```

### Example Output

[](#example-output)

```
[2024-01-15 10:30:45] [2.5ms] select * from `users` where `email` = ? ["user@example.com"]
[2024-01-15 10:30:45] [1.2ms] select * from `posts` where `user_id` = ? [1]
[2024-01-15 10:30:45] [0.8ms] select * from `comments` where `post_id` in (?, ?, ?) [1, 2, 3]
------------------------------------------------------------
[2024-01-15 10:31:12] [3.1ms] insert into `users` (`name`, `email`) values (?, ?) ["John Doe", "john@example.com"]
[2024-01-15 10:31:12] [1.5ms] select * from `users` where `id` = ? [42]
------------------------------------------------------------

```

Troubleshooting
---------------

[](#troubleshooting)

### Log file not created

[](#log-file-not-created)

1. Check `storage/logs` directory permissions: ```
    chmod 775 storage/logs
    chown www-data:www-data storage/logs
    ```
2. Verify `APP_DEBUG=true` in your `.env`
3. Check current environment is in `allowed_envs`
4. Ensure not running in console mode

### Empty or incomplete logs

[](#empty-or-incomplete-logs)

1. Try disabling file locking: ```
    'file_lock' => false,
    ```
2. Check disk space
3. Verify PHP has write permissions

### Performance issues

[](#performance-issues)

1. Set `file_lock' => false`
2. Only enable in specific environments
3. Monitor log file size

### Multiple separator lines

[](#multiple-separator-lines)

This indicates the service provider is being instantiated multiple times. Ensure:

- You're using the latest version
- `static $attached` property is working correctly
- Only one instance of the provider exists

Security Considerations
-----------------------

[](#security-considerations)

⚠️ **Important Security Notes:**

1. **Never enable in production** unless absolutely necessary
2. **SQL logs may contain sensitive data** (emails, passwords, personal info)
3. **Secure the log file:**```
    chmod 640 storage/logs/sql.log
    chown www-data:www-data storage/logs/sql.log
    ```
4. **Regularly rotate and delete old logs**

Support
-------

[](#support)

If you encounter any issues or have questions:

1. Check the [Troubleshooting](#troubleshooting) section
2. Search [existing issues](https://github.com/hesamzakerirad/laravel-sql-logger/issues)
3. Create a [new issue](https://github.com/hesamzakerirad/laravel-sql-logger/issues/new)

License
-------

[](#license)

This package is open-source software licensed under the MIT license.

Credits
-------

[](#credits)

- [Hesam Rad](https://github.com/hesamzakerirad)
- [All Contributors](../../contributors)

###  Health Score

36

—

LowBetter than 81% of packages

Maintenance87

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

93d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4942e3e9192a51df0a31f069fbf6ded0e0f656dd4aa02bd173f5ba9a4b2ba0bf?d=identicon)[hesamzakerirad](/maintainers/hesamzakerirad)

---

Top Contributors

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

---

Tags

laravellogsql

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[cviebrock/eloquent-sluggable

Easy creation of slugs for your Eloquent models in Laravel

4.0k13.6M251](/packages/cviebrock-eloquent-sluggable)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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