PHPackages                             ddelosreyes/http-requests-logger-for-laravel - 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. ddelosreyes/http-requests-logger-for-laravel

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

ddelosreyes/http-requests-logger-for-laravel
============================================

A simple HTTP request logger for Laravel with buffered inserts and support for both relational databases and DynamoDB.

v0.1.3(1mo ago)074MITPHPPHP ^8.2CI passing

Since May 9Pushed 1mo agoCompare

[ Source](https://github.com/delosreyesdan/http-requests-logger-for-laravel)[ Packagist](https://packagist.org/packages/ddelosreyes/http-requests-logger-for-laravel)[ RSS](/packages/ddelosreyes-http-requests-logger-for-laravel/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (10)Versions (5)Used By (0)

Http Requests Logger for Laravel
================================

[](#http-requests-logger-for-laravel)

> Work in progress — API may change before v1.0.

[![Latest Version on Packagist](https://camo.githubusercontent.com/088f494c6f8cd86eef24913e967778b194d75d80bb32e2983b6d89e5574698d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6464656c6f7372657965732f687474702d72657175657374732d6c6f676765722d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ddelosreyes/http-requests-logger-for-laravel)

Logs incoming and outgoing HTTP requests without hammering your database. Every request is pushed to a Redis/Valkey list first, then flushed to storage in batches — keeping per-request DB writes entirely off the hot path.

---

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

[](#requirements)

- PHP 8.2+
- Laravel 10, 11, or 12
- `ext-redis`

---

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

[](#installation)

```
composer require ddelosreyes/http-requests-logger-for-laravel
```

```
php artisan vendor:publish --provider="Ddelosreyes\HttpRequestsLogger\Providers\HttpRequestLoggerServiceProvider" --tag=config
php artisan vendor:publish --provider="Ddelosreyes\HttpRequestsLogger\Providers\HttpRequestLoggerServiceProvider" --tag=migrations
php artisan migrate
```

---

Usage
-----

[](#usage)

**Register the middleware** to log incoming requests:

```
// Laravel 11+ — bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\Ddelosreyes\HttpRequestsLogger\Middleware\HttpRequestLoggerMiddleware::class);
})

// Laravel 10 — app/Http/Kernel.php
protected $middleware = [
    \Ddelosreyes\HttpRequestsLogger\Middleware\HttpRequestLoggerMiddleware::class,
];
```

Each entry captures: `direction`, `method`, `url`, `status`, `ip`, `user_agent`, `headers`, `body`, `duration_ms`.

**Log outgoing requests** (Laravel `Http::` facade) by setting:

```
HTTP_REQUEST_LOGGER_LOG_OUTGOING=true
```

**Manually push a log** from anywhere:

```
use Ddelosreyes\HttpRequestsLogger\Facades\HttpRequestLogger;

HttpRequestLogger::add([...]);
```

Or via the action directly:

```
use Ddelosreyes\HttpRequestsLogger\Actions\RequestLogBufferAction;

RequestLogBufferAction::add([...]);
```

---

Commands
--------

[](#commands)

```
php artisan logs:flush          # drain the buffer to storage
php artisan logs:clear          # discard the buffer without persisting
php artisan logs:status         # show buffer key, count, batch size, fill %
php artisan logs:prune --days=30  # delete database records older than N days
```

The buffer flushes automatically when it reaches `batch_size`. For low-traffic apps that never hit that threshold, enable the built-in scheduled drain:

```
HTTP_REQUEST_LOGGER_SCHEDULE=true
HTTP_REQUEST_LOGGER_SCHEDULE_CRON="* * * * *"
```

Or wire it yourself:

```
Schedule::command('logs:flush')->everyMinute()->withoutOverlapping();
```

---

Querying Logs
-------------

[](#querying-logs)

An Eloquent model is provided with query scopes for common filters:

```
use Ddelosreyes\HttpRequestsLogger\Models\HttpRequestLog;

HttpRequestLog::incoming()->get();
HttpRequestLog::outgoing()->get();
HttpRequestLog::failed()->get();                    // status >= 400
HttpRequestLog::successful()->get();                // status < 400
HttpRequestLog::slow(500)->get();                   // duration_ms > 500
HttpRequestLog::withStatus(422)->get();
HttpRequestLog::fromIp('1.2.3.4')->get();
HttpRequestLog::forUrl('/api/users')->get();
HttpRequestLog::within(60)->get();                  // last 60 minutes
HttpRequestLog::forUser(42)->get();                 // by user ID
HttpRequestLog::withRequestId('abc-123')->get();    // by correlation ID
```

---

Sensitive Data Masking
----------------------

[](#sensitive-data-masking)

Fields listed under `mask.headers` and `mask.body` have their values replaced with `***` before the log is stored. Header matching is case-insensitive. Body masking is recursive.

```
'mask' => [
    'headers' => ['Authorization', 'Cookie', 'X-Api-Key'],
    'body'    => ['password', 'token', 'secret', 'credit_card'],
],
```

---

Response Body Logging
---------------------

[](#response-body-logging)

Disabled by default to avoid storing large payloads. Enable and cap the size:

```
HTTP_REQUEST_LOGGER_LOG_RESPONSE_BODY=true
HTTP_REQUEST_LOGGER_MAX_BODY_SIZE=10240
```

Bodies larger than `max_body_size` bytes are stored truncated with a `...[truncated]` suffix.

---

Storage Drivers
---------------

[](#storage-drivers)

Set via `HTTP_REQUEST_LOGGER_STORAGE`. Default: `database`.

DriverNotes`database`Any Laravel-supported DB (MySQL, PostgreSQL, SQLite). Single `INSERT` per batch.`dynamodb`Uses `batchWriteItem` in chunks of 25 with one unprocessed-item retry.`redis`Permanent Redis/Valkey list. Suitable for short-lived retention.`null`Discards all logs. Useful for disabling without touching the middleware.---

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

[](#configuration)

```
return [
    // Master on/off switch — disable without removing middleware registration
    'enabled'     => env('HTTP_REQUEST_LOGGER_ENABLED', true),

    'storage'    => env('HTTP_REQUEST_LOGGER_STORAGE', 'database'),
    'batch_size' => env('HTTP_REQUEST_LOGGER_BATCH_SIZE', 500),

    // Log only a fraction of requests (0.0–1.0). 0.1 = ~10% of traffic.
    'sample_rate' => env('HTTP_REQUEST_LOGGER_SAMPLE_RATE', 1.0),

    'table'      => env('HTTP_REQUEST_LOGGER_TABLE', 'http_request_logs'),
    // Point logs at a dedicated DB connection instead of the default
    'connection' => env('HTTP_REQUEST_LOGGER_DB_CONNECTION', null),

    // Write directly to storage if Redis is unavailable instead of crashing
    'fallback_on_buffer_error' => env('HTTP_REQUEST_LOGGER_FALLBACK', true),

    // Log outgoing Http:: requests via the ResponseReceived event
    'log_outgoing' => env('HTTP_REQUEST_LOGGER_LOG_OUTGOING', false),

    // Capture auth()->id() on each log entry
    'log_user_id' => env('HTTP_REQUEST_LOGGER_LOG_USER_ID', false),

    // Header used to read/generate a request correlation ID
    'correlation_id_header' => env('HTTP_REQUEST_LOGGER_CORRELATION_ID_HEADER', 'X-Request-ID'),

    // Capture response bodies (both incoming and outgoing)
    'log_response_body' => env('HTTP_REQUEST_LOGGER_LOG_RESPONSE_BODY', false),
    'max_body_size'     => env('HTTP_REQUEST_LOGGER_MAX_BODY_SIZE', 10240),

    'mask' => [
        'headers' => [], // e.g. ['Authorization', 'Cookie']
        'body'    => [], // e.g. ['password', 'token']
    ],

    'exclude' => [
        'fields' => [], // e.g. ['headers', 'body']
        'paths'  => [], // e.g. ['/health', '/api/internal/*']
    ],

    'redis' => [
        'driver'   => env('HTTP_REQUEST_LOGGER_BUFFER_DRIVER', 'redis'), // "redis" or "valkey"
        'host'     => env('REDIS_HOST', '127.0.0.1'),
        'port'     => env('REDIS_PORT', 6379),
        'password' => env('REDIS_PASSWORD', null),
        'database' => env('REDIS_DB', 0),
        'prefix'   => env('HTTP_REQUEST_LOGGER_KEY_PREFIX', 'http_request_logs'),
    ],

    'redis_store' => [
        'max_entries' => env('HTTP_REQUEST_LOGGER_REDIS_MAX_ENTRIES', 10000),
    ],

    'dynamodb' => [
        'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    ],

    'schedule' => [
        'enabled' => env('HTTP_REQUEST_LOGGER_SCHEDULE', false),
        'cron'    => env('HTTP_REQUEST_LOGGER_SCHEDULE_CRON', '* * * * *'),
    ],
];
```

---

Testing
-------

[](#testing)

Requires a running Redis/Valkey instance. Use the included Docker setup:

```
make build
make test
```

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance89

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

4

Last Release

55d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65170536?v=4)[ddelosreyes](/maintainers/ddelosreyes)[@ddelosreyes](https://github.com/ddelosreyes)

---

Top Contributors

[![delosreyesdan](https://avatars.githubusercontent.com/u/16068080?v=4)](https://github.com/delosreyesdan "delosreyesdan (15 commits)")

###  Code Quality

TestsPest

Static AnalysisRector

### Embed Badge

![Health badge](/badges/ddelosreyes-http-requests-logger-for-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/ddelosreyes-http-requests-logger-for-laravel/health.svg)](https://phpackages.com/packages/ddelosreyes-http-requests-logger-for-laravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k91.9k1](/packages/mike-bronner-laravel-model-caching)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

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