PHPackages                             moe-mizrak/laravel-log-reader - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. moe-mizrak/laravel-log-reader

ActivePackage[Logging &amp; Monitoring](/categories/logging)

moe-mizrak/laravel-log-reader
=============================

Lightweight Laravel package for reading, searching, and filtering logs from both file and database sources.

v0.1.0(6mo ago)0611MITPHPPHP ^8.4CI passing

Since Oct 14Pushed 6mo agoCompare

[ Source](https://github.com/moe-mizrak/laravel-log-reader)[ Packagist](https://packagist.org/packages/moe-mizrak/laravel-log-reader)[ Docs](https://github.com/moe-mizrak/laravel-log-reader)[ RSS](/packages/moe-mizrak-laravel-log-reader/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (4)Versions (8)Used By (1)

Laravel Log Reader
==================

[](#laravel-log-reader)

Lightweight Laravel package for searching and filtering logs from both file and database sources.

> This package provides the core log reading functionality used by the [Laravel MCP Log](https://github.com/laplace-demon-ai/laravel-mcp-log) (**MCP tool for Laravel log analysing with AI.**).

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

[](#installation)

You can install the package (that you created with this template) via composer:

```
composer require moe-mizrak/laravel-log-reader
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-log-reader"
```

Usage
-----

[](#usage)

You can use the package to read, search, and filter logs from both file and database sources.

If your logs are stored in files (`laravel.log`), in the config file (`laravel-log-reader.php`) set the **driver** to `file` as:

```
'driver' => env('LOG_READER_DRIVER', LogDriverType::FILE->value), // in .env file LOG_READER_DRIVER=file
```

And set the log file path as:

```
'path' => env('LOG_FILE_PATH', storage_path('logs/laravel.log')), // in .env file LOG_FILE_PATH=/full/path/to/laravel.log
```

And also you can set a limit, chunk size as:

```
'chunk_size' => env('LOG_READER_FILE_CHUNK_SIZE', 512 * 1024), // 512KB for file reading
'limit' => env('LOG_READER_FILE_QUERY_LIMIT', 10000),
```

Service provider automatically resolves the correct log reader (`FileLogReader`) and you can use it as:

```
use MoeMizrak\LaravelLogReader\Facades\LogReader;
use MoeMizrak\LaravelLogReader\Enums\FilterKeyType;

$query = 'User authentication';
$filters = [FilterKeyType::LEVEL->value => 'info'];

$result = LogReader::search($query)->filter($filters)->chunk()->execute();
```

If your logs are stored in database (`log_entries` table), in the config file (`laravel-log-reader.php`) set the **driver** to `db` as:

```
'driver' => env('LOG_READER_DRIVER', LogDriverType::DB->value), // in .env file LOG_READER_DRIVER=db
```

Set the connection and table name as:

```
'table' => env('LOG_DB_TABLE', 'log_entries'), // in .env file LOG_DB_TABLE=log_entries
'connection' => env('LOG_DB_CONNECTION'), // in .env file LOG_DB_CONNECTION=mysql
```

And set the database columns mapping and searchable columns as:

```
// Column mapping: maps DB columns to LogData properties
'columns' => [
    LogTableColumnType::ID->value => 'id',
    LogTableColumnType::LEVEL->value => 'level', // e.g. 'ERROR', 'INFO'
    LogTableColumnType::MESSAGE->value => 'message', // main log message
    LogTableColumnType::TIMESTAMP->value => 'created_at', // time of the log entry (e.g. 'created_at' or 'logged_at')
    LogTableColumnType::CHANNEL->value => 'channel', // e.g. 'production', 'local'
    LogTableColumnType::CONTEXT->value => 'context', // additional context info, often JSON e.g. '{"action":"UserLogin"}'
    LogTableColumnType::EXTRA->value => 'extra', // any extra data, often JSON e.g. '{"ip":172.0.0.1, "session_id":"abc", "user_id":123}'
],

'searchable_columns' => [
    ['name' => LogTableColumnType::MESSAGE->value, 'type' => ColumnType::TEXT->value],
    ['name' => LogTableColumnType::CONTEXT->value, 'type' => ColumnType::JSON->value],
    ['name' => LogTableColumnType::EXTRA->value, 'type' => ColumnType::JSON->value],
],
```

And also you can set a limit, chunk size as:

```
'limit' => env('LOG_READER_DB_QUERY_LIMIT', 10000), // max number of records to fetch in queries
'chunk_size' => env('LOG_READER_DB_CHUNK_SIZE', 500), // number of records per chunk when chunking is enabled
```

And you can use it as:

```
use MoeMizrak\LaravelLogReader\Facades\LogReader;
use MoeMizrak\LaravelLogReader\Enums\FilterKeyType;

$query = 'User authentication';
$filters = [FilterKeyType::DATE_FROM->value => '2025-01-01', FilterKeyType::DATE_TO->value => '2025-12-31'];

$result = LogReader::search($query)->filter($filters)->chunk()->execute();
```

> **Note:** You can chain the `search`, `filter`, and `chunk` methods in any order before calling `execute`. The `search` method performs a search on searchable fields (like message, context, etc.) based on the provided query (in config we have `searchable_columns` so that it can be customized).

TODO
----

[](#todo)

> - Add a `log_insights` migration/table which will be a normalized, summarized, and searchable table.
> - It unifies different log mechanisms into a single canonical format, enabling faster lookups over large data.
> - A background task should sync new log data periodically, basically everyday it summarizes the previous day's logs and inserts them into `log_insights`.
> - Be aware that summarization may lose some details (e.g., exact errors or stack traces).
> - Add support for cloud log readers (AWS CloudWatch, Azure Monitor, Google Cloud Logging).
> - Add streaming responses, either as a parameter to search/filter methods or as a new method like `searchStream` using cursors, yields, or `$builder->lazy($chunkSize)`.
> - Use a cheap/free model to summarize large log files before search/filter (experimental approach).
> - Refine `LOG_PATTERN` in `FileLogReader` to handle more real-world log formats.
> - Move `user_id`, `request_id`, and `ip_address` into dedicated columns instead of using the `extra` field.

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

[](#contributing)

> **Your contributions are welcome!** If you'd like to improve this project, simply create a pull request with your changes. Your efforts help enhance its functionality and documentation.

> If you find this project useful, please consider ⭐ it to show your support!

Authors
-------

[](#authors)

This project is created and maintained by [Moe Mizrak](https://github.com/moe-mizrak).

License
-------

[](#license)

Laravel Package Template is an open-sourced software licensed under the **[MIT license](LICENSE)**.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance66

Regular maintenance activity

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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 ~1 days

Total

7

Last Release

204d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/178c884a892aaf6813e8af8e2cb685bc987a168d9a0ebe9336455a795247ff96?d=identicon)[moe-mizrak](/maintainers/moe-mizrak)

---

Top Contributors

[![moe-mizrak](https://avatars.githubusercontent.com/u/12977885?v=4)](https://github.com/moe-mizrak "moe-mizrak (33 commits)")

---

Tags

laravelloggingphp8laravelphp-8Moe Mizraklaravel-log-reader

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/moe-mizrak-laravel-log-reader/health.svg)

```
[![Health](https://phpackages.com/badges/moe-mizrak-laravel-log-reader/health.svg)](https://phpackages.com/packages/moe-mizrak-laravel-log-reader)
```

###  Alternatives

[moe-mizrak/laravel-openrouter

Laravel package for OpenRouter (A unified interface for LLMs)

153107.2k2](/packages/moe-mizrak-laravel-openrouter)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

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