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

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

programic/laravel-http-logger
=============================

A Laravel package to log HTTP requests

v1.3.1(1y ago)0807MITPHPPHP ^7.4|^8.0

Since Apr 17Pushed 1y agoCompare

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

READMEChangelog (7)Dependencies (4)Versions (8)Used By (0)

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

[](#log-http-requests)

[![Latest Version on Packagist](https://camo.githubusercontent.com/799e29c43ad0e2667a5a0887f04e394759c6d09695351cd3c2ebf46a4423ced3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70726f6772616d69632f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/programic/laravel-http-logger)[![run-tests](https://github.com/programic/laravel-http-logger/actions/workflows/run-tests.yml/badge.svg)](https://github.com/programic/laravel-http-logger/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/e5844b8b7acb1bb4945a2c3e3332068e2c75c92b6ad155acc829f292a15ab968/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70726f6772616d69632f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/programic/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 can install the package via composer:

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

Optionally you can publish the config file with:

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

Optionally you can publish the migration file with:

```
php artisan vendor:publish --provider="Programic\HttpLogger\HttpLoggerServiceProvider" --tag="migrations"
```

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' => \Programic\HttpLogger\LogNonGetRequests::class,

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

    /*
     * The log channel used to write the request.
     */
    'log_channel' => env('LOG_CHANNEL', 'stack'),

    /*
     * The log level used to log the request.
     */
    'log_level' => 'info',

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

    /*
     * List of headers that will be sanitized. For example Authorization, Cookie, Set-Cookie...
     */
    'sanitize_headers' => [],
];
```

Usage
-----

[](#usage)

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

**Laravel &gt;= 11:**

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\Programic\HttpLogger\Middlewares\HttpLogger::class);
})
```

**Laravel &lt;= 10:**

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

protected $middleware = [
    // ...

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

```
// in a routes file

Route::post('/submit-form', function () {
    //
})->middleware(\Programic\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 `\Programic\HttpLogger\LogProfile`. This interface requires you to implement `shouldLogRequest`.

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

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

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

```
// Example implementation from `\Programic\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::channel(config('http-logger.log_channel'))->info($message);
}
```

#### Hide sensitive headers

[](#hide-sensitive-headers)

You can define headers that you want to sanitize before sending them to the log. The most common example would be Authorization header. If you don't want to log jwt token, you can add that header to `http-logger.php` config file:

```
// in config/http-logger.php

return [
    // ...

    'sanitize_headers' => [
        'Authorization'
    ],
];
```

Output would be `Authorization: "****"` instead of `Authorization: "Bearer {token}"`

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/programic/.github/blob/main/CONTRIBUTING.md) for details.

### Security

[](#security)

If you've found a bug regarding security please mail  instead of using the issue tracker.

Credits
-------

[](#credits)

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

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Every ~13 days

Recently: every ~19 days

Total

7

Last Release

680d ago

Major Versions

v0.2 → v1.02024-04-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/04de5632caf547d8dfa4ffbfac25d0538f92f1e9d52d2f91a2d1d6f17a9561a5?d=identicon)[Programic](/maintainers/Programic)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (74 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (27 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (13 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![rick-bongers](https://avatars.githubusercontent.com/u/67374906?v=4)](https://github.com/rick-bongers "rick-bongers (7 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (7 commits)")[![AyoobMH](https://avatars.githubusercontent.com/u/37803924?v=4)](https://github.com/AyoobMH "AyoobMH (7 commits)")[![rogervila](https://avatars.githubusercontent.com/u/6053012?v=4)](https://github.com/rogervila "rogervila (5 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (4 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (4 commits)")[![kudashevs](https://avatars.githubusercontent.com/u/15892462?v=4)](https://github.com/kudashevs "kudashevs (4 commits)")[![stfndamjanovic](https://avatars.githubusercontent.com/u/22433990?v=4)](https://github.com/stfndamjanovic "stfndamjanovic (3 commits)")[![SebastianSchoeps](https://avatars.githubusercontent.com/u/44115562?v=4)](https://github.com/SebastianSchoeps "SebastianSchoeps (2 commits)")[![timvandijck](https://avatars.githubusercontent.com/u/4528796?v=4)](https://github.com/timvandijck "timvandijck (2 commits)")[![tvbeek](https://avatars.githubusercontent.com/u/2026498?v=4)](https://github.com/tvbeek "tvbeek (1 commits)")[![angeljqv](https://avatars.githubusercontent.com/u/79208641?v=4)](https://github.com/angeljqv "angeljqv (1 commits)")[![dongido001](https://avatars.githubusercontent.com/u/18917158?v=4)](https://github.com/dongido001 "dongido001 (1 commits)")[![lsmith77](https://avatars.githubusercontent.com/u/300279?v=4)](https://github.com/lsmith77 "lsmith77 (1 commits)")[![Okipa](https://avatars.githubusercontent.com/u/5328934?v=4)](https://github.com/Okipa "Okipa (1 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (1 commits)")

---

Tags

laravel-http-loggerprogramic

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[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)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[kitloong/laravel-app-logger

Laravel log for your application

101.2M8](/packages/kitloong-laravel-app-logger)[label84/laravel-auth-log

Log user authentication actions in Laravel.

3654.0k](/packages/label84-laravel-auth-log)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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