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

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

dmeys/request-logger
====================

A Laravel/Lumen package to log requests and responses

v1(1y ago)05MITPHPPHP ^7.3|^8.0|8.2

Since Aug 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dmeys/request-logger)[ Packagist](https://packagist.org/packages/dmeys/request-logger)[ RSS](/packages/dmeys-request-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

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

Log request and response
========================

[](#log-request-and-response)

This package adds a middleware which can log incoming requests and responses. You can see the logs in view panel at `https://your.domain/request-logs`

Laravel Installation
--------------------

[](#laravel-installation)

You can install the package via composer:

```
composer require dmeys/request-logger
```

You must publish the asset files with:

```
php artisan vendor:publish --provider="Dmeys\RequestLogger\RequestLoggerServiceProvider"
```

You must publish the config file and assets with:

 request-logger.php```
return [
    'locale' => env('REQUEST_LOGGER_LOCALE', 'en'), // available 'en', 'ua'
    'middleware' => [
        \Dmeys\RequestLogger\Http\Middleware\BaseAuth::class,
    ],
    'base_auth' => [
        'login' => env('REQUEST_LOGGER_LOGIN', 'login'),
        'password' => env('REQUEST_LOGGER_PASSWORD', 'password'),
    ],
    'timezone' => env('REQUEST_LOGGER_TIMEZONE', env('APP_TIMEZONE', config('app.timezone', 'UTC'))),
    'date_format' => env('REQUEST_LOGGER_DATE_FORMAT', 'Y-m-d'),
    'time_format' => env('REQUEST_LOGGER_TIME_FORMAT', 'H:i:s.u'),
    'log_keep_days' => env('REQUEST_LOGGER_KEEP_DAYS', 14),
    'table_name' => 'request_logs',
    'enabled' => env('REQUEST_LOGGER_ENABLED', true),
    'ignore_paths' => [
        'request-logs*',
        'telescope*',
        'nova-api*',
    ],
    'hide_fields' => [
        'request' => [
            'headers' => [
                'authorization',
                'php-auth-user',
                'php-auth-pw',
            ],
            'content' => [
                'password',
                'token',
                'access_token',
            ],
        ],
        'response' => [
            'content' => [
                'password',
                'token',
                'access_token',
            ],
        ],
    ],
    'replacer_hidden_fields' => '|^_-|',
];
```

You have to execute migrations with:

```
    php artisan migrate --path=/vendor/dmeys/request-logger/database/migrations/2021_11_05_000000_create_request_log_fingerprints_table.php
    php artisan migrate --path=/vendor/dmeys/request-logger/database/migrations/2021_11_05_000000_create_request_logs_table.php
```

This packages provides a middleware which can be added as a global middleware or as a single route.

```
// in `app/Http/Kernel.php`

protected $middleware = [
    // ...

    \Dmeys\RequestLogger\Http\Middleware\RequestLogger::class
];
```

```
// in a routes file

Route::post('/test', function () {
    //
})->middleware(\Dmeys\RequestLogger\Http\Middleware\RequestLogger::class);
```

Supported drivers
-----------------

[](#supported-drivers)

- storage logs
- database (mysql)

Lumen Installation
------------------

[](#lumen-installation)

You can install the package via composer:

```
composer require dmeys/request-logger --dev
```

You must install [vendor:publish plugin](https://github.com/laravelista/lumen-vendor-publish)

You must register provider:

```
//in 'bootstrap/app.php'

$app->register(\Dmeys\RequestLogger\RequestLoggerServiceProvider::class);
```

You must publish the config file and assets with:

```
php artisan vendor:publish --provider="Dmeys\RequestLogger\RequestLoggerServiceProvider"
```

This is the contents of the published config file:

 request-logger.php```
return [
    'locale' => env('REQUEST_LOGGER_LOCALE', 'en'), // available 'en', 'ua'
    'middleware' => [
        \Dmeys\RequestLogger\Http\Middleware\BaseAuth::class,
    ],
    'base_auth' => [
        'login' => env('REQUEST_LOGGER_LOGIN', 'login'),
        'password' => env('REQUEST_LOGGER_PASSWORD', 'password'),
    ],
    'timezone' => env('REQUEST_LOGGER_TIMEZONE', env('APP_TIMEZONE', config('app.timezone', 'UTC'))),
    'date_format' => env('REQUEST_LOGGER_DATE_FORMAT', 'Y-m-d'),
    'time_format' => env('REQUEST_LOGGER_TIME_FORMAT', 'H:i:s.u'),
    'log_keep_days' => env('REQUEST_LOGGER_KEEP_DAYS', 14),
    'table_name' => 'request_logs',
    'enabled' => env('REQUEST_LOGGER_ENABLED', true),
    'ignore_paths' => [
        'request-logs*',
        'telescope*',
        'nova-api*',
    ],
    'hide_fields' => [
        'request' => [
            'headers' => [
                'authorization',
                'php-auth-user',
                'php-auth-pw',
            ],
            'content' => [
                'password',
                'token',
                'access_token',
            ],
        ],
        'response' => [
            'content' => [
                'password',
                'token',
                'access_token',
            ],
        ],
    ],
    'replacer_hidden_fields' => '|^_-|',
];
```

You must register this config file:

```
//in 'bootstrap/app.php'

$app->configure('request-logger');
```

You must execute migrations with:

```
php artisan migrate
```

You must create storage symbolic link with:

```
php artisan storage:link
```

You must register middleware:

```
// in 'bootstrap/app.php'

$app->routeMiddleware([
    // ...

    'request-logger' => \Dmeys\RequestLogger\Http\Middleware\RequestLogger::class,
]);
```

This packages provides a middleware which can be added as a global middleware or as a single route.

```
// in a routes file

Route::post('/test', ['uses' => 'TestController@test', 'middleware' => ['request-logger']]);
```

### Data Pruning

[](#data-pruning)

Without pruning, the `request_logs` table can accumulate records very quickly. To mitigate this, you should schedule the `request-logs:clear` artisan command to run daily:

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

Running the `php artisan request-logs:clear` command deletes recorded logs older than the number of days specified in the `log_keep_days` configuration.

To delete all logs, add the "--all" parameter `php artisan request-logs:clear --all`

### Configuration custom fields

[](#configuration-custom-fields)

The Request Logger allows you to add custom fields for logging. The package provides the `configureRequestLoggerCustomFields` function, which must return an array containing the custom fields. Additionally, make sure to add these custom fields to the database table `request_logs`.

Here's an example of using `configureRequestLoggerCustomFields()`:

- Add the middleware `ConfigureRequestLoggerMiddleware`.
- In the middleware, implement the `handle` method and specify custom fields using the `configureRequestLoggerCustomFields` function.

```
final class ConfigureRequestLoggerMiddleware
{
	public function handle(Request $request, Closure $next)
	{
		configureRequestLoggerCustomFields(function () use ($request) {
			return ['user_id' => $request->user()->id ?? null];
		});

		return $next($request);
	}
}
```

- Register the middleware in the Http Kernel.

These steps outline how to use the `configureRequestLoggerCustomFields` function to add custom fields to your logging setup.

### Testing

[](#testing)

```
php vendor/bin/phpunit
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

626d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e617cabdca9e5e0a09968886148a25b06470c2d0ce33cd4add1d902ab751b5b?d=identicon)[dmeys](/maintainers/dmeys)

---

Top Contributors

[![dmeys](https://avatars.githubusercontent.com/u/34945008?v=4)](https://github.com/dmeys "dmeys (1 commits)")

---

Tags

loglaraveldebugginglumenloggerrequest log

### Embed Badge

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

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

###  Alternatives

[hryha/laravel-request-logger

A Laravel package to log requests and responses

102.2k](/packages/hryha-laravel-request-logger)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)[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)

PHPackages © 2026

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