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

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

garbetjie/http-request-logger
=============================

A request logger that can log all incoming &amp; outgoing requests and responses.

5.1.0(4y ago)51.8k2MITPHPPHP ^7.3 || ^7.4 || ^8.0CI failing

Since Oct 22Pushed 4y ago2 watchersCompare

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

READMEChangelogDependencies (8)Versions (25)Used By (0)

HTTP Request Logger
-------------------

[](#http-request-logger)

An HTTP request logging library that makes it simple to easy to implement the logging of all HTTP requests &amp; responses.

Works with [Laravel](https://laravel.com/docs), [Guzzle](http://docs.guzzlephp.org) and PHP's `SoapServer` and `SoapClient` classes.

[![](https://github.com/garbetjie/http-request-logger/actions/workflows/tests.yaml/badge.svg)](https://github.com/garbetjie/http-request-logger/actions/workflows/tests.yaml/badge.svg)

Table of contents
=================

[](#table-of-contents)

- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
    - [Incoming requests: Laravel](#incoming-requests-in-laravel)
    - [Incoming requests: PSR-15 compliant frameworks](#incoming-requests-in-psr-15-compliant-frameworks)
    - [Incoming requests: SOAP server](#incoming-soap-requests)
    - [Outgoing requests: Laravel](#outgoing-requests-in-laravel)
    - [Outgoing requests: Guzzle](#outgoing-requests-through-guzzle)
    - [Outgoing requests: SOAP](#outgoing-soap-requests)
- [Customisation](#customisation)
    - [Context](#logging-context)
    - [Request &amp; response IDs](#id-generation)
    - [Toggling logging](#toggling-logging)
- [Changelog](#changelog)

Introduction
============

[](#introduction)

It is often quite useful to be able to see all requests &amp; responses generated by your application - especially whilst in development. This library makes it trivial to log all incoming &amp; outgoing requests &amp; responses using [Monolog](https://packagist.org/packages/monolog/monolog).

By default, all requests &amp; responses are logged at the `debug` log level. Sensible defaults for logging context are used, and headers that may contain sensitive values (such as `Cookie`, `Set-Cookie` and `Authorization`) have their values obfuscated. Each request &amp; corresponding response are linked together through a unique ID. This allows you to interrogate your logs to find the matching response for any given request.

Installation
============

[](#installation)

```
composer require garbetjie/http-request-logger
```

Usage
=====

[](#usage)

Incoming requests in Laravel
----------------------------

[](#incoming-requests-in-laravel)

Enabling request logging in Laravel is as simple as adding the middleware to the `$middleware` property on your `App\Http\Kernel` class. The example shown below is enough to ensure that all incoming requests &amp; outgoing responses are logged in Laravel:

```
