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

ActiveLibrary

san4io/request-logger
=====================

Laravel Request Response Logger

0.1.3(8y ago)0703MITPHPPHP &gt;=7.1

Since Nov 5Pushed 8y ago1 watchersCompare

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

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

Request Logger
==============

[](#request-logger)

[![Build Status](https://camo.githubusercontent.com/424626b171a93eaf072e3bffdec8226c1c31ab2256b521d9cb8dd9253a906453/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e34696f2f726571756573742d6c6f676765722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/san4io/request-logger/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ce072966b19d0b69c94b0ab29268f4456bd680c8f0a88bda7c9bc68d3ada4d07/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e34696f2f726571756573742d6c6f676765722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/san4io/request-logger/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/ec1b1dfcfc47c4fde36d439475460320fa76029b61bde9a61c4234a1fd7f1734/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e34696f2f726571756573742d6c6f676765722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/san4io/request-logger/?branch=master)

Package for logging Laravel HTTP requests. By default it uses **Monolog with LogStash** formatter, but it can be overriden in your ServiceProvider, check Advanced Configuration section.

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

[](#installation)

You can install the package via composer:

```
composer require san4io/request-logger
```

You can publish config

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

```

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

[](#configuration)

In `request-logger.php` config file you'll find current properties:

PropertyDefaultDescirptionstorage\_path/logs/request-logger.logWhere your logs gonna be storedparam\_exceptions\['password', 'password\_confirmation'\]which params should be filtered out from RequestParamsFormatterUsage
-----

[](#usage)

In global middleware:

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

protected $middleware = [
    ...

    \San4io\RequestLogger\Middleware\RequestLoggerMiddleware::class
];
```

In group of routes:

```
// in a routes file
Route::group(['middleware' => \San4io\RequestLogger\Middleware\RequestLoggerMiddleware::class], function () {
    //
});
```

In single route:

```
// in a routes file
Route::get('/', function () {
    //
})->middleware(\San4io\RequestLogger\Middleware\RequestLoggerMiddleware::class);
```

Default Log Context Formatters
------------------------------

[](#default-log-context-formatters)

FormatterNameDescirptionExampleRequestIPFormatterrequest\_ipReturns request ip information192.22.22.11RequestMethodFormatterrequest\_methodReturns request method informationPOSTRequestUriFormatterrequest\_uriReturns request uri informationRequestHeadersFormatterrequest\_headersReturns request headers information{cookie:\[Phpstorm-f176c91a=b5df2557-0cd3-44be-857d-7ea59b93c24a; io=Xm-fflHJzYnRSle0AAAB; JSESSIONID.41a4f06a=ux60gwkijzfr1cleylxjci7po;\], "origin":\["http://localhost"\], "accept":\["application/json"\]}RequestParamsFormatterrequest\_paramsReturns request params(**filtered**) information{"email":"qwe"}ResponseBenchmarkFormatterresponse\_msReturns execution time0.1858180046081543ResponseContentFormatterresponse\_contentReturn response content(**can be very heavy, use wisely**){"message":"The given data was invalid.","errors":{"email":\["The email must be a valid email address."\]}}Extending
---------

[](#extending)

You can extend your Logger with your own ContextFormatters.

Your context formatter should extend `\San4io\RequestLogger\Contracts\ContextFormatterContract` interface. In `format` method should return your desired output. In `name` method, you should return **unique** name of formatter

Advanced Configuration
----------------------

[](#advanced-configuration)

### Overriding Logger

[](#overriding-logger)

You can override logger in your ServiceProvider by binding your logger to `'app.request.logger'` For example you want other Formatter like MongoDBFormatter.

```
// YourServiceProvider.php
public function register()
{
    $this->app->bind('app.request.logger', function () {
        $logger = new Logger('request-logger');

        $handler = new RotatingFileHandler(
            storage_path(config('request-logger.storage_path'))
        );
        // Changing Handler
        $handler->setFormatter(new MongoDBFormatter(
            env('APP_NAME'),
            null,
            null,
            null
        ));

        $logger->pushHandler($handler);

        return $logger;
    });
}
```

That's it, you have setted logger with your desired formatter.

Or you can create your own logger with different name, and inject it to `RequestLogger` for example:

```
//YourServiceProvider.php
public function register()
{
    $this->app->bind('my_mega_super_dupper_logger', function () {
        ...

        return $logger;
    });

    $this->app->bind(RequestLogger::class, function (Application $app) {
        return new RequestLogger(
            // Injecting your logger
            $app->make('my_mega_super_dupper_logger'),
            $app->make(LogContextFormatter::class)
        );
    });
}
```

### Overriding LogContextFormatter

[](#overriding-logcontextformatter)

It is possible that you need some addidtional data to be returned to your log. In this case you extend `\San4io\RequestLogger\Contracts\ContextFormatterContract` interface (check Extending section) and adding it to LogContextFormatter. Example:

```
// YourServiceProvider.php
public function register()
{
    // Totally override LogContextFormatter, in this case it will return only your data.
    $this->app->bind(LogContextFormatter::class, function (Application $app) {
        $contextFormatter = new LogContextFormatter();

        $contextFormatter->addContextFormatter($app->make(YourContextFormatter::class));

        return $contextFormatter;
    });

    // Adding additional contexts to default ones.
    $this->app->bind(LogContextFormatter::class, function (Application $app) {
        $contextFormatter = $app->make(LogContextFormatter::class);

        $contextFormatter->addContextFormatter($app->make(YourContextFormatter::class));

        return $contextFormatter;
    });

}
```

Road map
--------

[](#road-map)

- Tests

Contribution
------------

[](#contribution)

Any contributions welcome!

Log Examples
------------

[](#log-examples)

```
{
   "@timestamp":"2017-11-05T13:49:24.308258+00:00",
   "@source":"3b1ceb06851b",
   "@fields":{
      "channel":"request-logger",
      "level":200,
      "request_ip":"192.22.22.11",
      "request_method":"POST",
      "request_uri":"http://localhost/api/v1/authenticate",
      "request_params":{
         "email":"qwe"
      },
      "request_headers":{
         "cookie":[
            "Phpstorm-f176c91a=b5df2557-0cd3-44be-857d-7ea59b93c24a; io=Xm-fflHJzYnRSle0AAAB; JSESSIONID.41a4f06a=ux60gwkijzfr1cleylxjci7po; _nsuid=d3c208ab-5937-4e2c-a974-7ae2c71b8c43; ns.welcomemessage.displayed=true; user=undefined; token=undefined; refreshToken=Bunn1cX7CBS1VdS%2BfbWAY12oQOD0utiDGW5jKAK06two2a0eWOMwxhetPiAe3Ao73IX5fP56UymvucykD6ZbXT4sJvyorXUR%2FNph%2FuamwK2zkE%2F%2Bh8iUqPzK5qluRWklHtZV0AXUTxjTEok3hcksRTus2uxLz3cff1JMpwXJwzEYT8Oi1WxVj8WU7XzTevskrvoil1gtRkQKKq5porjntD2nk3IU4vCNvA6HnlRIeHpz2uooXNZYRJzpbpbZBXQTUDPEu9g7psspBbhnBw87ymvxGUqrWaWr9axtDSalkuNA1UFOgoQO3hjR864xEhiGKfGVsZvQYov4I5OEDcbt45xmNE1ZE6thgSbZqGAGdQDIvnpJf%2FAkImy48sfJ4DIduziP9SBbJvgRmVblnyUDQshCg2Gm1dEi6nGuqr2iUbmzTYgACaWUkRL67oCG0fIq18vrpNcxXXbhKtd3SIHx1lrSRN%2Bg0IjFD30QnquvXpJ09OvoOp5WF6fbz5yjfrK4E%2BSg7QOEleKJZeVM2Ax2u%2BH2ED1GsWkuYy7L7GtfBAL7QfDOvY9DgFGtL4lXOxu8b10IHxI9806J1gARvFojwrpCi4wQpyui%2F9Y1WKbCK0ii2IXk6aBq%2F917znc%2FycXOFCTtxgv5O5t9ed9E7%2BYO75%2FOWCJibn%2FI2bSLGm8VC8U%3D; accessToken=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImVhZDA0MDJiYjM2YmY3Mjc2Y2UxMGUzNTYxNmU1NGEwY2RmZTMyY2M1MTQ1NjExNDQ0ZGQyMDhhNGQ3OGNiZWNhZWU5NjM5YzdiOGQ2YTllIn0.eyJhdWQiOiI1ODdkMmF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080"
         ],
         "accept-language":[
            "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,lt;q=0.6,it;q=0.5"
         ],
         "accept-encoding":[
            "gzip, deflate, br"
         ],
         "referer":[
            "http://localhost/api/documentation"
         ],
         "content-type":[
            "multipart/form-data; boundary=----WebKitFormBoundaryNm6iocezUxk36GAH"
         ],
         "user-agent":[
            "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/62.0.3202.62 Chrome/62.0.3202.62 Safari/537.36"
         ],
         "origin":[
            "http://localhost"
         ],
         "accept":[
            "application/json"
         ],
         "cache-control":[
            "no-cache"
         ],
         "pragma":[
            "no-cache"
         ],
         "content-length":[
            "237"
         ],
         "connection":[
            "keep-alive"
         ],
         "host":[
            "localhost"
         ]
      },
      "response_content":"{\"message\":\"The given data was invalid.\",\"errors\":{\"email\":[\"The email must be a valid email address.\"]}}",
      "response_ms":0.121142101287842
   },
   "@message":"POST http://localhost/api/v1/authenticate",
   "@tags":[
      "request-logger"
   ],
   "@type":"TestApplication"
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Every ~0 days

Total

4

Last Release

3111d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01483fcdda66c1a9389afd9e48829f17a4c22561da1be56b4fdd91b5e14d801d?d=identicon)[san4io](/maintainers/san4io)

---

Top Contributors

[![san4io](https://avatars.githubusercontent.com/u/12079341?v=4)](https://github.com/san4io "san4io (24 commits)")

### Embed Badge

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

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

###  Alternatives

[laravel/nightwatch

The official Laravel Nightwatch package.

3486.1M13](/packages/laravel-nightwatch)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)

PHPackages © 2026

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