PHPackages                             mbt/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. mbt/laravel-log-reader

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

mbt/laravel-log-reader
======================

A Laravel package for reading Laravel log files and returning structured JSON logs.

00

Since Jul 7Compare

[ Source](https://github.com/mohamadaliqurbani/laravel-log-reader)[ Packagist](https://packagist.org/packages/mbt/laravel-log-reader)[ RSS](/packages/mbt-laravel-log-reader/feed)WikiDiscussions Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

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

[](#laravel-log-reader)

A small Laravel package that reads Laravel `.log` files, parses entries like `storage/logs/laravel.log`, and returns them as JSON.

Install Locally
---------------

[](#install-locally)

If this package lives beside or inside a Laravel app, add it to the app's `composer.json`:

```
{
    "repositories": [
        {
            "type": "path",
            "url": "../laravelLog"
        }
    ],
    "require": {
        "mbt/laravel-log-reader": "*"
    }
}
```

Then run:

```
composer update mbt/laravel-log-reader
```

Laravel package discovery will register the service provider automatically.

Usage
-----

[](#usage)

By default, the package exposes:

```
GET /api/logs

```

Example response:

```
{
    "logs": [
        {
            "level": "info",
            "date": "2026-07-06 19:13:44",
            "file": "",
            "line": "",
            "message": "User logged in",
            "stacktrace": ""
        }
    ],
    "meta": {
        "current_page": 1,
        "from": 1,
        "last_page": 1,
        "per_page": 25,
        "to": 1,
        "total": 1,
        "search": null,
        "level": null,
        "order": "desc"
    },
    "links": {
        "prev": null,
        "next": null
    }
}
```

For exceptions, `file`, `line`, and `stacktrace` are filled when they can be detected from the log content.

Search And Pagination
---------------------

[](#search-and-pagination)

The `/api/logs` endpoint accepts these query parameters:

```
?search=payment
?level=error
?page=2
?per_page=25
?order=desc

```

Examples:

```
GET /api/logs?search=payment
GET /api/logs?level=error&page=1&per_page=10
GET /api/logs?order=asc

```

`search` checks the log level, date, file, line, message, and stack trace. `level` filters by exact log level, such as `info`, `warning`, or `error`.

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

[](#configuration)

Publish the config:

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

Available options:

```
return [
    'path' => storage_path('logs/laravel.log'),
    'route' => [
        'enabled' => true,
        'prefix' => 'api',
        'path' => 'logs',
        'middleware' => ['api'],
    ],
    'authorization' => [
        'ability' => null,
    ],
    'pagination' => [
        'per_page' => 25,
        'max_per_page' => 100,
        'order' => 'desc',
    ],
];
```

Authentication And Authorization
--------------------------------

[](#authentication-and-authorization)

Use authentication middleware before exposing this route outside development. Laravel logs can contain secrets, tokens, emails, SQL queries, and stack traces.

For a token-based API using Sanctum, publish the config and update the middleware:

```
'route' => [
    'enabled' => true,
    'prefix' => 'api',
    'path' => 'logs',
    'middleware' => ['api', 'auth:sanctum'],
],
```

Then request the route with a bearer token:

```
curl -H "Authorization: Bearer YOUR_TOKEN" http://127.0.0.1:8000/api/logs
```

To add authorization too, define a Gate in your Laravel app's `app/Providers/AppServiceProvider.php`:

```
use App\Models\User;
use Illuminate\Support\Facades\Gate;

public function boot(): void
{
    Gate::define('viewLaravelLogs', function (User $user) {
        return (bool) $user->is_admin;
    });
}
```

Then enable that ability in `config/laravel-log-reader.php`:

```
'authorization' => [
    'ability' => 'viewLaravelLogs',
],
```

Now `/api/logs` requires both a valid authenticated user and permission from the `viewLaravelLogs` Gate.

###  Health Score

9

—

LowBetter than 0% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/770816521d8060869bc0e104e295441eb4a433224fb1c2f53a0718b8e35faed0?d=identicon)[mohammadAliQurbani](/maintainers/mohammadAliQurbani)

### Embed Badge

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

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B11.7k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1941.5M285](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2328.5M353](/packages/open-telemetry-sdk)

PHPackages © 2026

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