PHPackages                             hryha/laravel-request-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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. hryha/laravel-request-logger

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

hryha/laravel-request-logger
============================

A Laravel package to log requests and responses

3.3.4(1mo ago)102.2k↓23.7%1MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Apr 3Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/vaniok010/laravel-request-logger)[ Packagist](https://packagist.org/packages/hryha/laravel-request-logger)[ Docs](https://github.com/vaniok010/laravel-request-logger)[ RSS](/packages/hryha-laravel-request-logger/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (21)Used By (0)

Request Logger for Laravel
==========================

[](#request-logger-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/442517cfe2fb3f8cb36e73ce5ab522c8a8816360606c61de700ca514c4b856c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68727968612f6c61726176656c2d726571756573742d6c6f676765722e737667)](https://packagist.org/packages/hryha/laravel-request-logger)[![Total Downloads](https://camo.githubusercontent.com/ce5aa765e2d197e677e7253649e550ae5ab695c1452d3400693d70ae5ece4e32/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68727968612f6c61726176656c2d726571756573742d6c6f676765722e737667)](https://packagist.org/packages/hryha/laravel-request-logger)[![PHP Version](https://camo.githubusercontent.com/187240af044d09d5b14a1d9d9ebdf3f7a993e4c7bc09bdb46b4ba661a891bf5b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d626c7565)](https://www.php.net/)[![Laravel Version](https://camo.githubusercontent.com/8e59528e3bffc0ff163d1ff38615457708a9335e49ff03e0e8e3046b6a65791d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312532422d627269676874677265656e)](https://laravel.com/)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md)

[![Laravel request logger](assets/demo.png)](assets/demo.png)

Overview
--------

[](#overview)

This package provides middleware that logs incoming HTTP requests and responses in Laravel applications. You can view your logs through a dedicated panel at `https://your.domain/request-logs`.

Features
--------

[](#features)

- HTTP request and response logging
- Web-based log viewer interface
- Duplicated requests detection
- Configurable data retention period
- Sensitive data masking
- Support for custom logging fields
- Sampling support - log only a percentage of requests
- Smart filtering - always log slow requests and requests with high memory usage

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 11 or higher

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

[](#installation)

Install the package via Composer:

```
composer require hryha/laravel-request-logger
```

After installing Request Logger, publish its assets and config using the `request-logs:install` Artisan command:

```
php artisan request-logs:install
```

View the complete configuration options: [here](config/request-logger.php).

After installing Request Logger, you should also run the `migrate` command in order to create the tables needed to store Request Logger's data:

```
php artisan migrate
```

Usage
-----

[](#usage)

The package provides middleware that can be registered either globally or on specific routes:

```
// In bootstrap/app.php for global middleware
return Application::configure(basePath: dirname(__DIR__))
    ->withMiddleware(function (Middleware $middleware): void {
        $middleware->prepend([
            \Hryha\RequestLogger\Http\Middleware\RequestLogger::class,
        ])
    })
```

```
// Or in your routes file for specific routes
Route::get('/user', [UserController::class, 'index'])->middleware(\Hryha\RequestLogger\Http\Middleware\RequestLogger::class);
```

Upgrading
---------

[](#upgrading)

After upgrading to any new Request Logger version, you should re-publish Request Logger's assets:

```
php artisan request-logs:publish
```

Data Pruning
------------

[](#data-pruning)

To prevent the `request_logs` table from growing too large, schedule the `request-logs:clear` command to run daily:

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('request-logs:clear')->daily();
```

The `request-logs:clear` command removes logs older than the number of days specified in your `log_keep_days`configuration. To delete all logs, use the --all parameter:

```
php artisan request-logs:clear --all
```

Custom Fields
-------------

[](#custom-fields)

The Request Logger supports additional custom fields for enhanced logging capabilities.

Use the `RequestLogger::addCustomField(key, value)` method to include additional data in your logs. Additional data can be added from anywhere in the application using this code:

```
use Hryha\RequestLogger\RequestLogger;

resolve(RequestLogger::class)->addCustomField('user_id', Auth::id());
```

also, to filter logs by this field, you can add this field to the settings

```
REQUEST_LOGGER_CUSTOM_FIELDS="user_id,other_field"
```

Sampling Configuration
----------------------

[](#sampling-configuration)

To reduce storage usage and improve performance on high-traffic applications, you can configure Request Logger to log only a percentage of requests.

### Basic Sampling

[](#basic-sampling)

Enable sampling in your `.env` file:

```
# Enable sampling
REQUEST_LOGGER_SAMPLING_ENABLED=true
# Log only 0.5% of successful requests (2xx)
REQUEST_LOGGER_SAMPLING_2XX=0.5
# Log 50% of redirects (3xx)
REQUEST_LOGGER_SAMPLING_3XX=50
# Log all client errors (4xx)
REQUEST_LOGGER_SAMPLING_4XX=100
# Log all server errors (5xx)
REQUEST_LOGGER_SAMPLING_5XX=100
```

**Note**: Sampling rates support up to 2 decimal places (e.g., 10.25%). Values with more precision are automatically rounded.

### Smart Filtering

[](#smart-filtering)

Always log critical requests regardless of sampling rate:

```
# Always log requests slower than 500ms
REQUEST_LOGGER_ALWAYS_LOG_SLOW=500
# Always log requests using more than 30MB memory
REQUEST_LOGGER_ALWAYS_LOG_HEAVY_MEMORY=30
```

### How Sampling Works

[](#how-sampling-works)

When sampling is enabled:

1. **Ignored paths** are checked first (never logged)
2. **Smart filters** are applied (slow requests, high memory usage)
3. If no smart filter matches, **sampling rate** is applied randomly
4. A value of `0` means never log, `100` means always log

Ignoring Paths
--------------

[](#ignoring-paths)

Configure paths to ignore by setting `REQUEST_LOGGER_IGNORE_PATHS` in your `.env` file:

```
REQUEST_LOGGER_IGNORE_PATHS="telescope*,horizon*,nova-api*"
```

These paths will never be logged, regardless of sampling configuration.

Panel authorization
-------------------

[](#panel-authorization)

Be sure to protect this panel from unauthorized access. We recommend using [Basic Auth](https://github.com/vaniok010/laravel-simple-basic-auth) middleware or something similar. To do this, add an auth `middleware` in `config/request-logger.php`

```
'middleware' => [
    \Hryha\SimpleBasicAuth\SimpleBasicAuth::class,
],
```

Testing
-------

[](#testing)

Run the test:

```
composer test
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95% 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 ~18 days

Recently: every ~1 days

Total

20

Last Release

53d ago

Major Versions

2.x-dev → 3.0.02025-11-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/5106a78f875ddeafb9a6a976d4b4cd19e7570ca689b3450e37f88b6c8fde2a73?d=identicon)[vaniok010](/maintainers/vaniok010)

---

Top Contributors

[![vaniok010](https://avatars.githubusercontent.com/u/6134702?v=4)](https://github.com/vaniok010 "vaniok010 (38 commits)")[![mharasym](https://avatars.githubusercontent.com/u/40171914?v=4)](https://github.com/mharasym "mharasym (2 commits)")

---

Tags

loglaraveldebuggingloggerlaravel loggerrequest log

###  Code Quality

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/hryha-laravel-request-logger/health.svg)

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

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[yzen.dev/mono-processor

This Processor will display in the logs bread crumbs by which you can more quickly and accurately identify the cause of the error.

116.1k](/packages/yzendev-mono-processor)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)

PHPackages © 2026

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