PHPackages                             bilfeldt/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. bilfeldt/laravel-request-logger

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

bilfeldt/laravel-request-logger
===============================

Log Laravel application request and responses for debugging or statistics

v3.9.1(2w ago)123184.2k—2.5%12[1 issues](https://github.com/bilfeldt/laravel-request-logger/issues)1MITPHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Nov 7Pushed 2w ago2 watchersCompare

[ Source](https://github.com/bilfeldt/laravel-request-logger)[ Packagist](https://packagist.org/packages/bilfeldt/laravel-request-logger)[ Docs](https://github.com/bilfeldt/laravel-request-logger)[ GitHub Sponsors](https://github.com/bilfeldt)[ RSS](/packages/bilfeldt-laravel-request-logger/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (24)Versions (24)Used By (1)

Flexible and extendable logging of Laravel application request and responses
============================================================================

[](#flexible-and-extendable-logging-of-laravel-application-request-and-responses)

[![bilfeldt/laravel-request-logger](art/banner.png)](art/banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/27cc1fc1b580d49968d56ed0e48e4248697653bacfaeb7a3c01cb6e6df237e33/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696c66656c64742f6c61726176656c2d726571756573742d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bilfeldt/laravel-request-logger)[![GitHub Tests Action Status](https://github.com/bilfeldt/laravel-request-logger/actions/workflows/run-tests.yml/badge.svg)](https://github.com/bilfeldt/laravel-request-logger/actions/workflows/run-tests.yml)[![StyleCI Code Style Status](https://camo.githubusercontent.com/7a788c259cf501aa9d4b8cfc987204690307dd272148812386063cba7248cdc8/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3432343932383337302f736869656c64)](https://github.styleci.io/repos/424928370/shield)[![Total Downloads](https://camo.githubusercontent.com/a52dfe2e7d2336bb36605b2004ce2b6e1b1299a783fa20add6fa330512152d82/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696c66656c64742f6c61726176656c2d726571756573742d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bilfeldt/laravel-request-logger)

Zero configuration logging of Requests and Responses to database or custom drivers in Laravel applications - no more issues debugging customer support requests.

VersionLaravelPHP1.\*8.\* | 9.\*7.4.\* | 8.0.\* | 8.1.\*2.\*10.\*8.1.\* | 8.2.\*3.\*10.\* | 11.\* | 12.\* | 13.\*8.1.\* | 8.2.\* | 8.3.\* | 8.4.\* | 8.5.\*Installation
------------

[](#installation)

You can install the package via composer:

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

Publish and run the migrations with:

```
php artisan vendor:publish --provider="Bilfeldt\RequestLogger\RequestLoggerServiceProvider" --tag="request-logger-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --provider="Bilfeldt\RequestLogger\RequestLoggerServiceProvider" --tag="request-logger-config"
```

Usage
-----

[](#usage)

It is possible to enable logging of all or some requests conditionally using one of the approaches below.

### Enable log via middleware (Recommended)

[](#enable-log-via-middleware-recommended)

This package comes with a convenient `requestlog` middleware that can be used to enable logging of request by simply registering the middleware on the routes (or route groups) you wish to log:

```
Route::middleware('requestlog')->get('/', function () {
    return 'Hello World';
});
```

### Enable via config file

[](#enable-via-config-file)

The config file includes some convenient settings for enabling logging of all or some requests:

```
// Enable all requests:
'log_methods' => ['*'],

// or enable all server errors
'log_statuses' => ['5**'],
```

### Enable log via request

[](#enable-log-via-request)

This package adds a macro on the `Illuminate\Http\Request` class making it possible to enable logging directly from the request:

```
/**
 * Index posts.
 *
 * @param  Request  $request
 * @return Response
 */
public function index(Request $request)
{
    $request->enableLog();

    //
}
```

Extending with custom Drivers
-----------------------------

[](#extending-with-custom-drivers)

This package implements the [Laravel Manager Class](https://inspector.dev/how-to-extend-laravel-with-driver-based-services/) making it possible to easily register custom drivers either in your application or by third party packages.

An `example` driver can be specified as middleware parameters:

```
Route::middleware('log:example')->get('/', function () {
    return 'Hello World';
});
```

or via request macro:

```
$request->enableLog('example');
```

Pruning
-------

[](#pruning)

The number of logged requests can quickly grow if you are not pruning the logs regularly. In order to keep the logs manageable, you can use the `prune` command to remove old logs as [described in the Laravel Docs](https://laravel.com/docs/8.x/eloquent#pruning-models):

```
$schedule->command('requestlog:prune')->daily();
```

Note that the default `RequestLog` model setup by this package will not be discovered as a "Prunable" model by Laravel default `model:prune` command as it does not reside in the `app/Models` directory. If you change this class in the configuration to a custom class this will be auto registered and the command above will be needless.

Notes and advises
-----------------

[](#notes-and-advises)

### Storing logs in a dedicated database

[](#storing-logs-in-a-dedicated-database)

The `RequestLog` model uses the application's default database connection. To store logs in a separate database (e.g. a dedicated logging database to keep them out of your main application data), set the `REQUEST_LOGGER_DB_CONNECTION` environment variable to a connection name configured in `config/database.php`:

```
REQUEST_LOGGER_DB_CONNECTION=logging
```

When using a connection that points at a different database than the `users` table, drop the `user_id` foreign key constraint in the migration — cross-database foreign keys cannot be enforced. Replace `foreignId('user_id')->constrained()->cascadeOnDelete()` with `unsignedBigInteger('user_id')->nullable()->index()`.

### Proxies and load balancers

[](#proxies-and-load-balancers)

When using proxies and/or load balancers then the IP address of the proxy/load balancer must be listed as a [Trusted Proxy](https://laravel.com/docs/8.x/requests#configuring-trusted-proxies) for the users IP address to be correctly logged as the IP of the proxy itself will be logged otherwise.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Anders Bilfeldt](https://github.com/bilfeldt)
- [Laravel Telescope](https://github.com/laravel/telescope/blob/master/src/Watchers/RequestWatcher.php): Collection of data from request/response is almost entirely taken from this package.
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance97

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 84.1% 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 ~84 days

Recently: every ~121 days

Total

21

Last Release

15d ago

Major Versions

v0.3.0 → v1.0.02021-11-12

v1.1.0 → v2.0.02023-05-01

v2.2.0 → v3.0.02023-09-29

PHP version history (7 changes)v0.1.0PHP ^7.4|^8.0

v1.1.0PHP ^7.4 || ^8.0

v2.0.0PHP ~8.2.0

v2.1.0PHP ~8.1.0 || ~8.2.0

v3.1.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

v3.4.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

v3.7.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3a2c705f296e9f064f1c4da39f1439aa95717aa9670e3f7d77fb0deb249507d?d=identicon)[bilfeldt](/maintainers/bilfeldt)

---

Top Contributors

[![bilfeldt](https://avatars.githubusercontent.com/u/30228807?v=4)](https://github.com/bilfeldt "bilfeldt (127 commits)")[![onlime](https://avatars.githubusercontent.com/u/2759561?v=4)](https://github.com/onlime "onlime (7 commits)")[![MuriloChianfa](https://avatars.githubusercontent.com/u/60560085?v=4)](https://github.com/MuriloChianfa "MuriloChianfa (4 commits)")[![DevHoracioRodriguez](https://avatars.githubusercontent.com/u/7793925?v=4)](https://github.com/DevHoracioRodriguez "DevHoracioRodriguez (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![woenel](https://avatars.githubusercontent.com/u/8844488?v=4)](https://github.com/woenel "woenel (2 commits)")[![comes](https://avatars.githubusercontent.com/u/592262?v=4)](https://github.com/comes "comes (2 commits)")[![milhouse1337](https://avatars.githubusercontent.com/u/326740?v=4)](https://github.com/milhouse1337 "milhouse1337 (1 commits)")

---

Tags

laravelbilfeldtlaravel-request-logger

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[opcodesio/log-viewer

Fast and easy-to-use log viewer for your Laravel application

4.4k10.9M83](/packages/opcodesio-log-viewer)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[psalm/plugin-laravel

Psalm plugin for Laravel

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

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[bilfeldt/laravel-route-statistics

Log statistics about route usage per user/team

242148.4k2](/packages/bilfeldt-laravel-route-statistics)[inspector-apm/inspector-laravel

Code Execution Monitoring, built for developers.

2382.1M5](/packages/inspector-apm-inspector-laravel)

PHPackages © 2026

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