PHPackages                             anik/loguzz - 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. anik/loguzz

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

anik/loguzz
===========

Loguzz is a guzzlehttp/guzzle request &amp; response logger

v4.0(1y ago)16224.1k↓44.4%54MITPHPPHP ^8.0

Since Mar 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ssi-anik/loguzz)[ Packagist](https://packagist.org/packages/anik/loguzz)[ RSS](/packages/anik-loguzz/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (5)Versions (9)Used By (4)

Loguzz [![codecov](https://camo.githubusercontent.com/f42898fbcb11609145cc14a2eb262d2bdf2fef87b6ab1a543f03c38c17c0a189/68747470733a2f2f636f6465636f762e696f2f67682f7373692d616e696b2f6c6f67757a7a2f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4c33354856445a393156)](https://codecov.io/gh/ssi-anik/loguzz)[![Total Downloads](https://camo.githubusercontent.com/edf47ae3a79e1c8218bdbf6ecb40b7c4355ed1289f7623412a134ad7c7f1a81e/68747470733a2f2f706f7365722e707567782e6f72672f616e696b2f6c6f67757a7a2f646f776e6c6f616473)](//packagist.org/packages/anik/loguzz)[![Latest Stable Version](https://camo.githubusercontent.com/c264f72ae077e4c5322007f1938b7e7c3bb8d39d2e01e0217c7e7d82ba5194ef/68747470733a2f2f706f7365722e707567782e6f72672f616e696b2f6c6f67757a7a2f76)](//packagist.org/packages/anik/loguzz)
==============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#loguzz)

Loguzz is a middleware for [Guzzle](https://github.com/guzzle/guzzle) which logs requests and responses.

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

[](#installation)

You'll need composer to install the package. `composer require anik/loguzz`

Documentation V1
----------------

[](#documentation-v1)

Find the thorough [documentation here](https://bit.ly/3dwgYB1).

Documentation V4/V3/V2
----------------------

[](#documentation-v4v3v2)

To log a request, you'll need to push `Loguzz\Middleware\LogMiddleware` to Guzzle's handler.

```
$logger = new \ColinODell\PsrTestLogger\TestLogger();
$handlerStack = \GuzzleHttp\HandlerStack::create();
$options = [];
$handlerStack->push(new \Loguzz\Middleware\LogMiddleware($logger, $options), 'logger');
```

- `$logger` is the implementation of `Psr\Log\LoggerInterface`.
- `$options` is an array to change the default behaviour of LogMiddleware.
- `'logger'` is the internal name of the middleware for Guzzle. It can be any name.

### Options

[](#options)

```
// Default values
$options = [
    'length' => 100,
    'log_request' => true,
    'log_response' => true,
    'success_only' => false,
    'exceptions_only' => false,
    'log_level' => 'debug',
    'request_formatter' => new \Loguzz\Formatter\RequestCurlFormatter(),
    'response_formatter' => new \Loguzz\Formatter\ResponseJsonFormatter(),
    'exception_formatter' => new \Loguzz\Formatter\ExceptionJsonFormatter(),
    'tag' => '',
    'force_json' => true,
    'separate' => false,
];
```

- `length` - **int**. Minimum 10. To set the length of when formatting request with `\Loguzz\Formatter\RequestCurlFormatter`.
- `log_request` - **bool**. To enable or disable request logging.
- `log_response` - **bool**. To enable or disable response logging.
- `success_only` - **bool**. Only log successful responses. **If the server could be reached, it's a success.**
- `exception_only` - **bool** Only log exceptions. **Logs when an exception is thrown by Guzzle for connection/timeout related exceptions**.
- `log_level` - **string**. Any valid log level.
- `request_formatter` - instance of **\\Loguzz\\Formatter\\AbstractRequestFormatter**. Available
    - `\Loguzz\Formatter\RequestArrayFormatter`
    - `\Loguzz\Formatter\RequestCurlFormatter`
    - `\Loguzz\Formatter\RequestJsonFormatter`
- `response_formatter` - instance of **\\Loguzz\\Formatter\\AbstractResponseFormatter**
    - `\Loguzz\Formatter\ResponseArrayFormatter`
    - `\Loguzz\Formatter\ResponseJsonFormatter`
- `exception_formatter` - instance of **\\Loguzz\\Formatter\\AbstractResponseFormatter**
    - `\Loguzz\Formatter\ExceptionArrayFormatter`
    - `\Loguzz\Formatter\ExceptionJsonFormatter`
- `tag` - **string**. **Empty** by default. When non-empty string, it'll log the formatted data under this tag. Tag can be used to search for specific type of request/response in your log file or your storage.
- `force_json` - **bool**. **true** by default. It is only applicable when **tag** is non-empty string. If enabled, it will then log data as json string, otherwise it'll log as an array. **If set to** `false`, **the code may break due to the type-hint in psr/log interface. If your [logger interface supports array](https://github.com/laravel/framework/blob/dd5c5178274e64d0384dc30bf2c8139b00dba098/src/Illuminate/Log/Logger.php#L260), it will work.**
- `separate` - **bool**. It is only applicable when **tag** is non-empty string. If enabled, it will then log data in `{tag}.request`, `{tag}.success`, `{tag}.failure` for request logging, successful response and error response.

### Request Formatter

[](#request-formatter)

To create a new request formatter you need to **extend** the `\Loguzz\Formatter\AbstractRequestFormatter` class.

### Response Formatter

[](#response-formatter)

To create a new response formatter you need to **extend** the `\Loguzz\Formatter\AbstractResponseFormatter` class.

### Exception Formatter

[](#exception-formatter)

To create a new exception formatter you need to **extend** the `\Loguzz\Formatter\AbstractExceptionFormatter` class.

Manual Request formatting
-------------------------

[](#manual-request-formatting)

Implementations of `\Loguzz\Formatter\AbstractRequestFormatter::format` accept parameters as

- `\Psr\Http\Message\RequestInterface $request`
- `array $options = []`

Available request formatters parse data from `$request` and **cookies** from the `$options`. The values in `$options['cookies']` must be an implementation of `\GuzzleHttp\Cookie\CookieJarInterface`. To parse **cookies**, the request URL must contain the **domain**.

Manual Response formatting
--------------------------

[](#manual-response-formatting)

Implementations of `\Loguzz\Formatter\AbstractResponseFormatter::format` accept parameters as

- `\Psr\Http\Message\RequestInterface $request`
- `\Psr\Http\Message\ResponseInterface $response`
- `array $options = []`

Available response formatters parse data from `$response` and **cookies** from the `set-cookie` header. To parse **cookies**, the request URL must contain the **domain**.

The `set-cookie` headers will not be available in the headers for available response formatters.

Issues &amp; PRs
----------------

[](#issues--prs)

If you think something is missing in the package or cause bug, please report an Issue. If you're available and want to contribute to the repository, please submit a PR.

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 95.1% 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 ~230 days

Recently: every ~263 days

Total

8

Last Release

651d ago

Major Versions

v1.2 → v2.02021-10-09

v2.2 → v3.02023-08-05

v3.0 → v4.02024-08-28

PHP version history (2 changes)v1.0PHP &gt;=7.1

v3.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7180f132fd7bfbbec2083528838f87996e01a6165ef50e58e2f3fcfccda1a834?d=identicon)[ssi-anik](/maintainers/ssi-anik)

---

Top Contributors

[![ssi-anik](https://avatars.githubusercontent.com/u/2676602?v=4)](https://github.com/ssi-anik "ssi-anik (77 commits)")[![ls5302](https://avatars.githubusercontent.com/u/13901919?v=4)](https://github.com/ls5302 "ls5302 (2 commits)")[![colinmollenhour](https://avatars.githubusercontent.com/u/38738?v=4)](https://github.com/colinmollenhour "colinmollenhour (1 commits)")[![msvrtan](https://avatars.githubusercontent.com/u/1780572?v=4)](https://github.com/msvrtan "msvrtan (1 commits)")

---

Tags

guzzlehttplaravellogginglumenrequestsresponses

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anik-loguzz/health.svg)

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k532.1M2.5k](/packages/aws-aws-sdk-php)[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M395](/packages/drupal-core-recommended)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[eliashaeussler/cache-warmup

Composer package to warm up website caches, based on a given XML sitemap

75419.2k9](/packages/eliashaeussler-cache-warmup)

PHPackages © 2026

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