PHPackages                             andriichuk/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. [HTTP &amp; Networking](/categories/http)
4. /
5. andriichuk/laravel-http-logger

ActiveLibrary[HTTP &amp; Networking](/categories/http)

andriichuk/laravel-http-logger
==============================

Configurable HTTP request and response logger for Laravel, ideal for APIs. Optional file-upload metadata logging.

0.2.7(1mo ago)457—0%[1 PRs](https://github.com/andriichuk/laravel-http-logger/pulls)MITPHPPHP ^8.3CI passing

Since Mar 7Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (12)Versions (14)Used By (0)

Laravel HTTP Logger
===================

[](#laravel-http-logger)

[![Latest Version on Packagist](https://camo.githubusercontent.com/99ba52610fd38b2eaaec5ebbeede2863d14ad33bfc16c9e73d7817618827d773/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e647269696368756b2f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andriichuk/laravel-http-logger)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0d75c1c989306389e1b63b8a768da4befe3e137df7a1d5bf4b183e8cd69633cc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e647269696368756b2f6c61726176656c2d687474702d6c6f676765722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/andriichuk/laravel-http-logger/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a28f432f37201846c68b0b1363fc67a365c6aa731c507e758bc0b4c6afc942eb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616e647269696368756b2f6c61726176656c2d687474702d6c6f676765722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/andriichuk/laravel-http-logger/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ee7752b494e66d2df6aba862953fed9745349df6f43068242db457b60e04dd84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e647269696368756b2f6c61726176656c2d687474702d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andriichuk/laravel-http-logger)

A **super simple**, configurable HTTP request and response logger for Laravel, ideal for APIs.

- **Sanitization** — Mask sensitive fields and headers (e.g. password, authorization).
- **Filters** — Limit by route patterns and response status (2xx, 4xx, 5xx, etc.).
- **Headers** — Choose which request/response headers to include in logs.
- **Session errors** — Optionally include flashed validation errors in log context.
- **File uploads** — Optionally log uploaded file metadata (name, size, MIME type); no file contents.

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

[](#installation)

**Requirements:** PHP 8.3+ and Laravel 11.x or 12.x.

Install the package via Composer:

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

Publish the config file:

```
php artisan vendor:publish --tag="http-logger-config"
```

(Optional) Add a dedicated log channel for HTTP logs in `config/logging.php` (e.g. a separate file or stack). If you skip this, the package uses your default log channel.

```
'channels' => [
    // ...
    'http' => [
        'driver' => 'daily',
        'path' => storage_path('logs/http.log'),
        'level' => 'info',
    ],
],
```

> **Important — when is logging on?** If `LOG_HTTP_REQUESTS` is not set in `.env`, the logger follows **`APP_DEBUG`**: it is enabled when `APP_DEBUG=true` (e.g. local) and disabled when `APP_DEBUG=false` (e.g. production). To force it on or off, set **`LOG_HTTP_REQUESTS=true`** or **`LOG_HTTP_REQUESTS=false`** in your `.env`, or set `'enabled'` in `config/http-logger.php`. The log channel can be overridden with **`HTTP_LOG_CHANNEL`** (e.g. `HTTP_LOG_CHANNEL=http` to use the channel above).

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

[](#configuration)

After publishing, configure `config/http-logger.php` as needed.

KeyDescriptionDefault`enabled`Master switch for HTTP logging. When `LOG_HTTP_REQUESTS` is unset, falls back to `APP_DEBUG`.`env('LOG_HTTP_REQUESTS', APP_DEBUG)``channel`Log channel name (must exist in `config/logging.php`).`HTTP_LOG_CHANNEL` or `LOG_CHANNEL` or `'daily'``routes`Laravel route patterns to log (with or without leading slash). `[]` = none; `['*']` = all; `['/api/*']` = API only.`['*']``report`Which response status categories to log: `info` (1xx), `success` (2xx), `redirect` (3xx), `client_error` (4xx), `server_error` (5xx). Each key is a boolean.`info`/`success` → `false`; `redirect`/`client_error`/`server_error` → `true``log_level_by_status`Map each status category to a PSR log level (`debug`, `info`, `notice`, `warning`, `error`, etc.). 5xx → `error` and 4xx → `warning` by default for easier filtering.`client_error` → `warning`; `server_error` → `error`; others → `info``include_response`Include response body in log context.`true``include_non_json_response`When `include_response` is true, include non-JSON bodies (HTML, text, etc.) in the log (truncated). Set to `true` to include them; default logs as `'[skipped]'`.`false``include_request_headers`Request header names (lowercase) to include. Use `['*']` for all.`['*']``include_response_headers`Response header names (lowercase) to include. Use `['*']` for all.`[]``sensitive_fields`Request/response body keys to replace with `***`.`['token', 'refresh_token', 'password', …]``sensitive_headers`Header names (lowercase) to replace with `***`.`['authorization', 'cookie']``max_string_value_length`Max length for string values in bodies (and non-JSON response body) before truncation. Use `null` to disable truncation.`100``message_prefix`Prefix for the log message.`'[HttpLogger] '``include_host_in_message`Include request origin (protocol + host, e.g. `https://example.com`) in the log message.`false``include_session_errors`When true, add flashed validation errors (e.g. from `redirect()->withErrors()`) to log context as `session_errors`. Read-only; does not consume flash.`false``include_uploaded_files_metadata`When true, add metadata for uploaded files (original name, size, MIME type, extension) to log context as `uploaded_files`. No file contents are logged.`true`**Response body logging:** JSON responses are decoded and sanitized; `max_string_value_length` applies to each string value. Non-JSON responses are logged as a truncated string or `'[skipped]'`. The log **level** follows response status by default (5xx → `error`, 4xx → `warning`, 1xx/2xx/3xx → `info`); configure via `log_level_by_status`.

### Example log output

[](#example-log-output)

**API validation error (422):** `WARNING` level, authorization and cookie masked, JSON response with validation errors.

```
[2026-03-08 12:02:01] local.WARNING: [HttpLogger] POST /v1/guest/autologin {"response_status_code":422,"request_headers":{"host":["api.example.com"],"content-type":["application/json"],"authorization":"***","cookie":"***"},"response_headers":[],"request_body":{"device":{"id":"device-hash","app_version":"1.0.0","model":"Pixel 10","platform":"android","os_version":"12.0.0"}},"response_body":{"message":"The device.locale field is required.","errors":{"device.locale":["The device.locale field is required."]}}}

```

**API file upload validation error (422):** `WARNING` level, file input shown as `[object]` in request body, `uploaded_files` metadata (name, size, mime\_type, etc.) in context.

```
[2026-03-08 12:12:45] testing.WARNING: [HttpLogger] POST /api/profile/avatar {"response_status_code":422,"request_headers":{"host":["example.test"],"content-type":["application/x-www-form-urlencoded"],"x-app-version":["1.0.0"]},"response_headers":[],"request_body":{"avatar":"[object]"},"response_body":{"message":"The profile photo field must be an image. (and 1 more error)","errors":{"avatar":["The profile photo field must be an image.","The profile photo field must be a file of type: jpeg, jpg, png, gif, webp."]}},"uploaded_files":[{"name":"avatar","original_name":"document.pdf","size":102400,"mime_type":"application/pdf","extension":"pdf","error":0}]}

```

**Web auth form (redirect with flash):** `INFO` level, sensitive headers and fields masked, non-JSON response logged as `[skipped]`, `session_errors` with flashed validation message (e.g. login failure). Set `include_session_errors` to `true` in your config to get `session_errors` in the log.

```
[2026-03-08 12:25:04] local.INFO: [HttpLogger] POST /login {"response_status_code":302,"request_headers":{"host":["example.test"],"content-type":["application/x-www-form-urlencoded"],"cookie":"***"},"response_headers":[],"request_body":{"_token":"***","email":"user@example.com","password":"***"},"response_body":"[skipped]","session_errors":{"email":["These credentials do not match our records."]}}

```

Testing
-------

[](#testing)

Run the test suite with Pest:

```
composer test
```

Changelog
---------

[](#changelog)

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

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Serhii Andriichuk](https://github.com/andriichuk)
- [All Contributors](https://github.com/andriichuk/laravel-http-logger/contributors)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance89

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.5% 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 ~1 days

Total

12

Last Release

53d ago

PHP version history (2 changes)0.1.0PHP ^8.4

0.1.1PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc16718c1c07d5bacc569130cc001fdad5a7598d92b9d76f47236426aa09a363?d=identicon)[andriichuk](/maintainers/andriichuk)

---

Top Contributors

[![andriichuk](https://avatars.githubusercontent.com/u/38154251?v=4)](https://github.com/andriichuk "andriichuk (29 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

httphttp-loggerlaravelloggerlogginghttplaravelloggingloggerhttp-logger

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

29428.0k](/packages/sunchayn-nimbus)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[middlewares/access-log

Middleware to generate access logs

20121.2k2](/packages/middlewares-access-log)[pdphilip/cf-request

Cloudflare Laravel Request

2725.6k1](/packages/pdphilip-cf-request)

PHPackages © 2026

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