PHPackages                             hoangphison/laravel-http-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. hoangphison/laravel-http-logger

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

hoangphison/laravel-http-logger
===============================

A Laravel 5 package to log HTTP requests

v1.0.0(8y ago)015MITPHPPHP &gt;=5.6.4

Since Oct 17Pushed 8y agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

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

[](#log-http-requests)

[![Build Status](https://camo.githubusercontent.com/184ae3181cb1278bf68bb39e77cee6734d4030dfa59b045c999e2ff8e190473b/68747470733a2f2f7472617669732d63692e6f72672f686f616e67706869736f6e2f6c61726176656c2d687474702d6c6f676765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hoangphison/laravel-http-logger)[![StyleCI](https://camo.githubusercontent.com/5beb1550dc480f64409564d18b9da8fb6f41dd4ded5c3962b08cfe1abb52f491/68747470733a2f2f7374796c6563692e696f2f7265706f732f3130373335353739392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/107355799)

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 can install the package via composer:

```
composer require hoangphison/laravel-http-logger
```

Optionally you can publish the configfile with:

```
php artisan vendor:publish --provider="Spatie\HttpLogger\HttpLoggerServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [

    /*
     * The log profile which determines whether a request should be logged.
     * It should implement `LogProfile`.
     */
    'log_profile' => \Spatie\HttpLogger\LogNonGetRequests::class,

    /*
     * The log writer used to write the request to a log.
     * It should implement `LogWriter`.
     */
    'log_writer' => \Spatie\HttpLogger\DefaultLogWriter::class,

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

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

    \Spatie\HttpLogger\Middlewares\HttpLogger::class
];
```

```
// in a routes file

Route::post('/submit-form', function () {
    //
})->middleware(\Spatie\HttpLogger\Middlewares\HttpLogger::class);
```

### 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 `\Spatie\HttpLogger\LogProfile`. This interface requires you to implement `shouldLogRequest`.

```
// Example implementation from `\Spatie\HttpLogger\LogNonGetRequests`

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

A custom log writer must implement `\Spatie\HttpLogger\LogWriter`. This interface requires you to implement `logRequest`.

```
// Example implementation from `\Spatie\HttpLogger\DefaultLogWriter`

public function logRequest(Request $request): void
{
    $method = strtoupper($request->getMethod());

    $uri = $request->getPathInfo();

    $bodyAsJson = json_encode($request->except(config('http-logger.except')));

    $message = "{$method} {$uri} - {$bodyAsJson}";

    Log::info($message);
}
```

### Testing

[](#testing)

```
composer test
```

### 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

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

3089d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/516402738c16a9d7707d638d399b4b2c40cfc27776e8d5e25eea26ee58265b9f?d=identicon)[sonhp](/maintainers/sonhp)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (31 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (25 commits)")[![hoangphison](https://avatars.githubusercontent.com/u/9270621?v=4)](https://github.com/hoangphison "hoangphison (8 commits)")[![pdewit](https://avatars.githubusercontent.com/u/488574?v=4)](https://github.com/pdewit "pdewit (1 commits)")

---

Tags

spatielaravel-http-loggerhoangphison

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-activitylog

A very simple activity logger to monitor the users of your website or application

5.8k45.4M309](/packages/spatie-laravel-activitylog)[spatie/laravel-http-logger

A Laravel package to log HTTP requests

6744.4M11](/packages/spatie-laravel-http-logger)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[spatie/laravel-uptime-monitor

A powerful, easy to configure uptime monitor

1.1k234.4k8](/packages/spatie-laravel-uptime-monitor)[spatie/laravel-log-dumper

A function to dump anything to the log

122573.0k4](/packages/spatie-laravel-log-dumper)

PHPackages © 2026

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