PHPackages                             bit-mx/saloon-logger-plug-in - 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. bit-mx/saloon-logger-plug-in

ActiveLaravel-package[Logging &amp; Monitoring](/categories/logging)

bit-mx/saloon-logger-plug-in
============================

0.3.4(5mo ago)0128MITPHPPHP ^8.2

Since Oct 27Pushed 5mo agoCompare

[ Source](https://github.com/bit-mx/saloon-logger-plug-in)[ Packagist](https://packagist.org/packages/bit-mx/saloon-logger-plug-in)[ RSS](/packages/bit-mx-saloon-logger-plug-in/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (11)Versions (9)Used By (0)

Saloon Logger Plug-in
=====================

[](#saloon-logger-plug-in)

A Laravel plug-in for the Saloon HTTP client [Saloon v3](https://docs.saloon.dev/upgrade/whats-new-in-v3) that provides automatic observability and traceability for all HTTP interactions made with the Saloon library.

This package transparently logs requests, responses and exceptions to the database, and links all events using a single trace\_id (ULID).

Features
--------

[](#features)

- Traceability: Generates a unique identifier to tie the request, response and any exception together.
- Transparent integration: Enable logging simply by applying traits to the connector and request classes.
- Data sanitization: Automatically censors sensitive fields (for example passwords or authentication tokens) in logged payloads and headers.
- Reliable storage: Uses a dedicated database table for structured storage of logs.

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

[](#installation)

### Requirements

[](#requirements)

```
{
  "php": "^8.2",
  "laravel/framework": "^v12.35.0",
  "saloonphp/saloon": "^3.0"
}
```

### Install via Composer

[](#install-via-composer)

Install the package using Composer:

> composer require bit-mx/saloon-logger-plug-in

### Publish and run migrations

[](#publish-and-run-migrations)

This command will publish the migration into your `database/migrations` directory:

> php artisan vendor:publish --tag=saloon-logger-migrations

Then run the migrations:

> php artisan migrate

### Publish configuration (optional)

[](#publish-configuration-optional)

You can publish the configuration file to customize which fields are censored:

> php artisan vendor:publish --tag=saloon-logger-config

This will create `config/saloon-logger.php`.

Usage
-----

[](#usage)

### Step 1: Apply the Traits

[](#step-1-apply-the-traits)

To enable traceability, add the `HasLogging` trait to your connector and the `ProvidesDefaultBody` trait to your request.

Connector example:

```
use BitMx\SaloonLoggerPlugIn\Traits\HasLogging;
use Saloon\Http\Connector;

class ExampleConnector extends Connector
{
    use HasLogging;

    public function resolveBaseUrl(): string
    {
        return 'https://example.com';
    }
}
```

Request example:

```
use BitMx\SaloonLoggerPlugIn\Traits\ProvidesDefaultBody;
use BitMx\SaloonLoggerPlugIn\Contracts\HasDefaultBody;
use Saloon\Enums\Method;
use Saloon\Http\Request;

class ExampleRequest extends Request  implements HasDefaultBody
{
    use ProvidesDefaultBody;

    public function __construct(
        public string $id,
    ) {}

    protected Method $method = Method::GET;

    public function resolveEndpoint(): string
    {
        return '/test';
    }

    protected function defaultBody(): array
    {
        return [
            'id' => $this->id,
        ];
    }
}
```

### Step 2: Send the Request

[](#step-2-send-the-request)

Whenever a request is sent through this connector, the package will automatically log the events to the database table.

```
$connector = new ExampleConnector;
$request = new ExampleRequest($id);
$connector->send($request);
```

If an HTTP or network exception occurs (for example a 500), the package will log the request and the exception.

### Other languages

[](#other-languages)

[Spanish](./README_es.md)

Custom sanitizers
-----------------

[](#custom-sanitizers)

If you need a custom way to sanitize payloads or headers before they are stored, implement the `SanitizerRequestContract` and register your class in the package configuration under the `sanitizers.request` array.

Example request custom sanitizer:

```
namespace App\Sanitizers;

use BitMx\SaloonLoggerPlugIn\Contracts\SanitizerRequestContract;

class MyRequestSanitizer implements SanitizerRequestContract
{
    public static function sanitize(mixed $data): mixed
    {
        // perform your custom sanitization here
        return $data;
    }
}
```

If you need a custom way to sanitize the response before they are stored, implement the `SanitizerResponseContract` and register your class in the package configuration under the `sanitizers.response` array.

Example Response custom sanitizer:

```
namespace App\Sanitizers;

use BitMx\SaloonLoggerPlugIn\Contracts\SanitizerResponseContract;
use Saloon\Http\Response;

class MyResponseSanitizer implements SanitizerResponseContract
{
    public static function sanitize(Response $data): mixed
    {
        // perform your custom sanitization here
        return $data;
    }
}
```

Then register it in `config/saloon-logger.php`:

```
'sanitizers' => [
        'request' => [
            \BitMx\SaloonLoggerPlugIn\Sanitizers\Request\JsonSanitizerRequest::class,
            \App\Sanitizers\MyRequestSanitizer::class,
        ],
        'response' => [
            \BitMx\SaloonLoggerPlugIn\Sanitizers\Response\JsonSanitizerResponse::class,
            \App\Sanitizers\MyResponseSanitizer::class,
        ],
    ],
```

Sanitizers are applied in the order they appear in the configuration. Each sanitizer receives the data and must return the updated value.

Prune &amp; Backup
==================

[](#prune--backup)

You can configure the package to prune old records and make a backup of the records. The options are available separately in the configuration file

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance69

Regular maintenance activity

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.8% 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 ~2 days

Total

7

Last Release

179d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ec257b9dda4e1e687cdb07de95577588d5804841fc56089bfc01b7f70a2aa77?d=identicon)[jenriquez](/maintainers/jenriquez)

---

Top Contributors

[![emontano-bit](https://avatars.githubusercontent.com/u/115505444?v=4)](https://github.com/emontano-bit "emontano-bit (14 commits)")[![emontano-dev](https://avatars.githubusercontent.com/u/88910290?v=4)](https://github.com/emontano-dev "emontano-dev (11 commits)")[![EdX9](https://avatars.githubusercontent.com/u/36487489?v=4)](https://github.com/EdX9 "EdX9 (1 commits)")

---

Tags

apilaravelloggingsaloontracer

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bit-mx-saloon-logger-plug-in/health.svg)

```
[![Health](https://phpackages.com/badges/bit-mx-saloon-logger-plug-in/health.svg)](https://phpackages.com/packages/bit-mx-saloon-logger-plug-in)
```

###  Alternatives

[moesif/moesif-laravel

Moesif Collection/Data Ingestion Middleware for Laravel

1065.8k](/packages/moesif-moesif-laravel)[hosmelq/laravel-logsnag

Integrate the power of LogSnag's real-time event tracking into your Laravel application.

237.9k](/packages/hosmelq-laravel-logsnag)

PHPackages © 2026

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