PHPackages                             knovator/httplogger - 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. knovator/httplogger

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

knovator/httplogger
===================

This is http logger description

v1.0.10(7y ago)03PHP

Since Jan 26Pushed 4y ago2 watchersCompare

[ Source](https://github.com/knovator/httplogger)[ Packagist](https://packagist.org/packages/knovator/httplogger)[ RSS](/packages/knovator-httplogger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (13)Used By (0)

Log HTTP requests
=================

[](#log-http-requests)

[![Latest Version on Packagist](https://camo.githubusercontent.com/61685982b5ca7db340cf3f5d43ab4f2959c5f6b9b4a75d79861346e9d87bbd30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-http-logger)[![Build Status](https://camo.githubusercontent.com/440a7d3d47a1758a115e6a7034b8100e6eb0f839996d45397a733d296a2e4f04/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f6c61726176656c2d687474702d6c6f676765722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/laravel-http-logger)[![Quality Score](https://camo.githubusercontent.com/43cc0a43f68c4feffe76e70536a869b3cb48bc6f5d0aa8561949e695bb4feee8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-http-logger)[![Total Downloads](https://camo.githubusercontent.com/4a529fe2f90d2d9c9657f61dd269c00e89e0b648508aa7e063def28e71d73c00/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-http-logger)

This package adds a middleware which can log incoming requests to the default log. If anything goes wrong during a user's request, you'll still be able to access the original request data sent by that user.

This log acts as an extra safety net for critical user submissions, such as forms that generate leads.

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

[](#installation)

You want to need add http logger repository in your composer.json file.

```
"repositories": [
       {
           "type": "vcs",
           "url": "http://github.com/knovator/logger.git"
       }
   ],

```

Disable or add secure http flag in your composer.json file.

```
"config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "secure-http":false
    },

```

You can install the package via composer:

```
composer require knovator/httplogger "1.0.*"
```

You want to need add HttpLoggerServiceProvider provider in config/app.php.

```
    Knovator\HttpLogger\HttpLoggerServiceProvider::class,

```

Optionally you can publish the config file with:

```
php artisan vendor:publish --tag=config
```

This is the contents of the published config file:

```
return [

   /*
       * Filter out body fields which will never be logged.
       */
       'except'      => [
           'password',
           'password_confirmation',
       ],

       /* Default log channel.*/
       'log_channel' => 'custom_log',

        /* logged user columns */
       'action_by_columns' => [
           'id',
           'first_name',
           'last_name',
           'email',
           'phone'
       ],

];
```

Usage
-----

[](#usage)

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 = [
    // ...

    \Knovator\HttpLogger\Middleware\HttpLoggerMiddleware::class
];
```

Add channel in your configuration file .

```
// in `config/logging.php`

    'custom_log' => [
            'driver' => 'daily',
            'path'   => env('HTTP_LOGGER_FILE_NAME') ? storage_path('logs/' . env('HTTP_LOGGER_FILE_NAME') . '.log') : storage_path('logs/laravel.log'),
        ],
```

### Logging

[](#logging)

Two classes are used to handle the logging of incoming requests: a `LogProfile` class will determine whether the request should be logged, and `LogWriter` class will write the request to a log.

A default log implementation is added within this package. It will only log `POST`, `PUT`, `PATCH`, and `DELETE` requests and it will write to the default Laravel logger.

You're free to implement your own log profile and/or log writer classes, and configure it in `config/http-logger.php`.

A custom log profile must implement `\knovator\logger\src\LogProfile`. This interface requires you to implement `shouldLogRequest`.

```
// Example implementation from `\knovator\logger\src\LogNonGetRequests`

public function shouldLogRequest(Request $request): bool
{
   return in_array(strtolower($request->method()), ['post', 'put', 'patch', 'delete']);
}
```

A custom log writer must implement `\knovator\logger\src\LogWriter`. This interface requires you to implement `logRequest`.

```
// Example implementation from `\knovator\http-logger\src\DefaultLogWriter`

 public function logRequest(Request $request) {
        $fileNames = [];
        $method = strtoupper($request->getMethod());
        $uri = $request->getPathInfo();
        $bodyAsJson = json_encode($this->input($request, config('http-logger.except')));
        $message = "{$method} {$uri} - Action From: {$this->clientInformation($request)} - Body: {$bodyAsJson}";
        $this->uploadedFiles($request->files, $fileNames);

        if (!empty($fileNames)) {
            $message .= " - Files: " . json_encode($fileNames);
        }

        if (auth()->guard('api')->check()) {
            $user = auth()->guard('api')->user()->first(config('http-logger.action_by_columns'))
                          ->toArray();
            $userBody = json_encode($user);
            $message .= " - Action By: {$userBody}";
        }

        $channel = config('http-logger.log_channel');

        Log::channel($channel)->info($message);
    }
```

### Changelog

[](#changelog)

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

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

[](#contributing)

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

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Postcardware
------------

[](#postcardware)

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).

Credits
-------

[](#credits)

- [Brent Roose](https://github.com/brendt)
- [All Contributors](../../contributors)

Support us
----------

[](#support-us)

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

Does your business depend on our contributions? Reach out and support us on [Patreon](https://www.patreon.com/spatie). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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 ~2 days

Total

11

Last Release

2650d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12df943627abd214afbe75644882d9a59e2b1f5bb29d599c27f8fa310d3326d1?d=identicon)[jenishpaghadar](/maintainers/jenishpaghadar)

---

Top Contributors

[![jenishpaghadal](https://avatars.githubusercontent.com/u/13597693?v=4)](https://github.com/jenishpaghadal "jenishpaghadal (2 commits)")

### Embed Badge

![Health badge](/badges/knovator-httplogger/health.svg)

```
[![Health](https://phpackages.com/badges/knovator-httplogger/health.svg)](https://phpackages.com/packages/knovator-httplogger)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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