PHPackages                             bytetcore/lalog - 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. bytetcore/lalog

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

bytetcore/lalog
===============

A robust Laravel SQL Query Logger that logs all database queries to files with rotation, performance metrics, and cross-database compatibility.

1.0.2(yesterday)13↑2900%Apache-2.0PHPPHP ^8.0

Since Apr 3Pushed yesterdayCompare

[ Source](https://github.com/ByteTCore/lalog)[ Packagist](https://packagist.org/packages/bytetcore/lalog)[ RSS](/packages/bytetcore-lalog/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

Lalog - Laravel SQL Query Logger
================================

[](#lalog---laravel-sql-query-logger)

[![Latest Version](https://camo.githubusercontent.com/67fe7f28b282d64911fc90244ef52808ff152e8c0cab010e20144405b6dd0c3f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4279746554436f72652f6c616c6f67)](https://packagist.org/packages/ByteTCore/lalog)[![License](https://camo.githubusercontent.com/be51b546ab0b1cb8ee36b9d8b86df345bd1ac27a9d31df9fb599e296f05e476f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f4279746554436f72652f6c616c6f67)](https://packagist.org/packages/ByteTCore/lalog)[![Latest Stable Version](https://camo.githubusercontent.com/600a7eefc72039f0e326da79d4c3c4d9044469298358f34a33455c929579a298/687474703a2f2f706f7365722e707567782e6f72672f4279746554436f72652f6c616c6f672f76)](https://packagist.org/packages/ByteTCore/lalog)[![Total Downloads](https://camo.githubusercontent.com/6519fa4c0da62fbace09aed2657a5f0dbd598a1860fba4e277ea0f042d04419f/687474703a2f2f706f7365722e707567782e6f72672f4279746554436f72652f6c616c6f672f646f776e6c6f616473)](https://packagist.org/packages/ByteTCore/lalog)[![Latest Unstable Version](https://camo.githubusercontent.com/a1fbd9aafb7f28d10a76b07c462b6bfc613bb7cf547c1cb7a055037663ef47df/687474703a2f2f706f7365722e707567782e6f72672f4279746554436f72652f6c616c6f672f762f756e737461626c65)](https://packagist.org/packages/ByteTCore/lalog)

Automatically log all SQL queries to files with **binding interpolation**, **time tracking**, and **file rotation** support. Perfect for debugging and performance analysis during development.

Features
--------

[](#features)

- 🔍 **Full SQL Logging** — Captures every query with bindings interpolated
- ⏱️ **Query Time** — Records execution time for each query
- 📁 **File Rotation** — Automatically creates new files when size limit is reached
- 🗑️ **Auto Clear** — Optionally clears previous logs each request cycle
- ⚙️ **Configurable** — Disk, directory, format, max size, extension — all customizable
- 🚀 **Zero Config** — Works out of the box with sensible defaults

Requirements
------------

[](#requirements)

- PHP 8.0+
- Laravel 9.x+

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

[](#installation)

```
composer require bytetcore/lalog --dev
```

The package auto-discovers its ServiceProvider. No manual registration needed.

### Publish Config (Optional)

[](#publish-config-optional)

```
php artisan vendor:publish --tag=lalog-config
```

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

[](#configuration)

Add to your `.env`:

```
APP_LOG_QUERY=true
```

### Available Options

[](#available-options)

OptionEnv VariableDefaultDescription`enabled``APP_LOG_QUERY``false`Enable/disable query logging`disk``LALOG_DISK``local`Storage disk (any disk from `filesystems.php`)`directory``LALOG_DIRECTORY``query`Directory within the disk`max_size``LALOG_MAX_SIZE``2000000`Max file size in bytes (~2MB)`format``LALOG_FORMAT``sql-{date}`File name format (`{date}` placeholder)`date_format``LALOG_DATE_FORMAT``Y-m-d`PHP date format for `{date}``extension``LALOG_EXTENSION``sql`File extension`clear_on_start``LALOG_CLEAR_ON_START``true`Delete current day's log on start### Example Config

[](#example-config)

```
// config/lalog.php
return [
    'enabled'        => env('APP_LOG_QUERY', false),
    'disk'           => env('LALOG_DISK', 'local'),
    'directory'      => env('LALOG_DIRECTORY', 'query'),
    'max_size'       => env('LALOG_MAX_SIZE', 2000000),
    'format'         => env('LALOG_FORMAT', 'sql-{date}'),
    'date_format'    => env('LALOG_DATE_FORMAT', 'Y-m-d'),
    'extension'      => env('LALOG_EXTENSION', 'sql'),
    'clear_on_start' => env('LALOG_CLEAR_ON_START', true),
];
```

Output Example
--------------

[](#output-example)

File: `storage/app/query/sql-2026-04-03.sql`

```
----------START---------
Date: 2026-04-03 13:45:12
Time query: 2.34(ms)
select * from `users` where `email` = 'john@example.com' limit 1;
----------END----------

Date: 2026-04-03 13:45:12
Time query: 0.89(ms)
select * from `posts` where `user_id` = '1' order by `created_at` desc;
----------END----------
```

File Rotation
-------------

[](#file-rotation)

When a log file exceeds `max_size`, new files are created with an incremented index:

```
query/sql-2026-04-03.sql      (2MB reached)
query/sql-2026-04-03-1.sql    (next file)
query/sql-2026-04-03-2.sql    (and so on)

```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

See [AUTHORS](AUTHORS.md) for the list of contributors.

License
-------

[](#license)

Licensed under the Apache License 2.0. Please see [License File](LICENSE) for more information.

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

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

Every ~0 days

Total

3

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3be00157eb3b2afdf3024f93dcbe423e0fc71180431eccf5e48fe73f4d71d40d?d=identicon)[dovutuan](/maintainers/dovutuan)

---

Top Contributors

[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

loglaravelloggingdebugdatabaseperformancesqleloquentquery

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/bytetcore-lalog/health.svg)

```
[![Health](https://phpackages.com/badges/bytetcore-lalog/health.svg)](https://phpackages.com/packages/bytetcore-lalog)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M91](/packages/owen-it-laravel-auditing)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M24](/packages/tucker-eric-eloquentfilter)[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.0M14](/packages/rennokki-laravel-eloquent-query-cache)[danielme85/laravel-log-to-db

Custom Laravel Log channel handler that can store log events to SQL or MongoDB databases. Uses Laravel native logging functionality.

135934.5k1](/packages/danielme85-laravel-log-to-db)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M12](/packages/reedware-laravel-relation-joins)[altek/accountant

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

92954.3k4](/packages/altek-accountant)

PHPackages © 2026

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