PHPackages                             slogger/laravel - 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. slogger/laravel

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

slogger/laravel
===============

Tracing and observability for Laravel with dispatchers, masking, and profiling.

v1.1.0(1mo ago)1949↓50%MITPHPPHP ^8.2CI passing

Since Jan 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/sprust/slogger-laravel)[ Packagist](https://packagist.org/packages/slogger/laravel)[ RSS](/packages/slogger-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (27)Used By (0)

SLogger Laravel
===============

[](#slogger-laravel)

SLogger Laravel is a tracing/observability package for Laravel apps. It records request/command/job/event/etc. traces and delivers them to a remote backend via configurable dispatchers.

This README documents installation, configuration, watchers, masking, dispatchers, profiling, and usage patterns.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Laravel 10+ (tested), should work on Laravel 12
- Queue driver for `queue` dispatcher
- Optional: XHProf extension for profiling

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

[](#installation)

1. Install the package (via Composer in your app):

```
composer require slogger/slogger-laravel
```

2. Publish config:

```
php artisan vendor:publish --tag=slogger-laravel
```

3. Configure env and `config/slogger.php` (see below).

Quick Start
-----------

[](#quick-start)

Enable and use the queue dispatcher:

```
SLOGGER_ENABLED=true
SLOGGER_TOKEN=your-api-token
SLOGGER_DISPATCHER=queue
SLOGGER_DISPATCHER_QUEUE_CONNECTION=redis
SLOGGER_DISPATCHER_QUEUE_NAME=slogger
SLOGGER_DISPATCHER_QUEUE_HTTP_CLIENT_URL=https://your-slogger-api
SLOGGER_LOG_REQUESTS_ENABLED=true
```

Then start dispatcher workers:

```
php artisan slogger:dispatcher:start
```

Trace Collection Backend
------------------------

[](#trace-collection-backend)

SLogger Laravel sends traces to a separate backend service. The reference backend project is:

```
https://github.com/sprust/slogger

```

Use its setup instructions to provision the server and configure the API client URL/token in this package.

### Custom backend / client

[](#custom-backend--client)

You can replace the backend by providing your own API client. Redefine `ApiClientFactory::create` and return a custom implementation of `SLoggerLaravel\\Dispatcher\\ApiClients\\ApiClientInterface` that sends traces to your backend.

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

[](#configuration)

All configuration lives in `config/slogger.php` with environment overrides. Key sections:

### General

[](#general)

```
SLOGGER_ENABLED=false
SLOGGER_TOKEN=
SLOGGER_TRACE_ID_PREFIX=
SLOGGER_LOG_CHANNEL=daily
```

- `SLOGGER_ENABLED`: globally toggle all tracing.
- `SLOGGER_TOKEN`: API token for dispatchers.
- `SLOGGER_TRACE_ID_PREFIX`: custom prefix for trace IDs. If empty, uses slugged `app.name` or `app`.
- `SLOGGER_LOG_CHANNEL`: where internal errors are logged.

### Dispatchers

[](#dispatchers)

```
SLOGGER_DISPATCHER=queue
SLOGGER_DISPATCHER_QUEUE_CONNECTION="${QUEUE_CONNECTION}"
SLOGGER_DISPATCHER_QUEUE_NAME=slogger
SLOGGER_DISPATCHER_QUEUE_WORKERS_COUNT=3
SLOGGER_DISPATCHER_QUEUE_API_CLIENT=http
SLOGGER_DISPATCHER_QUEUE_HTTP_CLIENT_URL=http://0.0.0.0:0001
SLOGGER_DISPATCHER_QUEUE_SOCKET_CLIENT_URL=tcp://0.0.0.0:0002
```

- `SLOGGER_DISPATCHER`: `queue` or `memory`.
- `queue` dispatcher runs worker processes (similar to Horizon) and sends traces via HTTP or socket client.
- `memory` dispatcher stores traces in memory (useful for tests/dev).

### Profiling

[](#profiling)

```
SLOGGER_PROFILING_ENABLED=true
```

Enables XHProf profiling for HTTP client traces (see Profiling section).

### Request parent trace header

[](#request-parent-trace-header)

```
SLOGGER_REQUESTS_HEADER_PARENT_TRACE_ID_KEY=x-parent-trace-id
```

Allows linking child traces to parent requests via a custom header.

### Watchers (enable/disable)

[](#watchers-enabledisable)

```
SLOGGER_LOG_COMMANDS_ENABLED=true
SLOGGER_LOG_JOBS_ENABLED=true
SLOGGER_LOG_REQUESTS_ENABLED=true
SLOGGER_LOG_CACHE_ENABLED=true
SLOGGER_LOG_DATABASE_ENABLED=true
SLOGGER_LOG_DUMP_ENABLED=true
SLOGGER_LOG_EVENT_ENABLED=true
SLOGGER_LOG_GATE_ENABLED=true
SLOGGER_LOG_HTTP_ENABLED=true
SLOGGER_LOG_LOG_ENABLED=true
SLOGGER_LOG_MAIL_ENABLED=true
SLOGGER_LOG_MODEL_ENABLED=true
SLOGGER_LOG_NOTIFICATION_ENABLED=true
SLOGGER_LOG_SCHEDULE_ENABLED=true
```

What SLogger Writes
-------------------

[](#what-slogger-writes)

Each trace contains:

- `trace_id`, `parent_trace_id`, `type`, `status`, `tags`
- `data` (watcher-specific payload)
- `duration`, `memory`, `cpu`, `logged_at`

Watcher data highlights:

- `request`: url, method, action, headers/params, response (for JSON responses)
- `job`: connection, payload, status, exception
- `event`: listeners, broadcast, optional serialized payload
- `model`: action, model class, key, changes
- `mail`: from/to/cc/bcc, subject, queued, mailable/notification
- `notification`: notifiable, channel, queued, response
- `cache`: type, key, tags, value
- `db`: query, bindings, time
- `http-client`: method, url, request/response
- `schedule`: command, description, cron, output
- `dump`, `log`, `gate`: dump/message/ability info

Requests
--------

[](#requests)

### Middleware

[](#middleware)

For HTTP request tracing, add the middleware to the routes you want traced:

```
\SLoggerLaravel\Middleware\HttpMiddleware::class
```

### Request watcher config

[](#request-watcher-config)

`config/slogger.php`:

```
'watchers' => [
    [
        'class'   => \SLoggerLaravel\Watchers\Parents\RequestWatcher::class,
        'enabled' => env('SLOGGER_LOG_REQUESTS_ENABLED', false),
        'config'  => [
            // log only matched paths (optional)
            'only_paths' => [
                // 'api/*',
            ],

            // skip matched paths
            'excepted_paths' => [
                // 'health',
            ],

            'input' => [
                // apply input formatting only for these paths
                'only_paths' => [
                    // 'api/*',
                ],

                // hide all request params for these paths
                'hidden_paths' => [
                    // 'auth/*',
                ],

                // header masking by url_pattern
                'headers_masking' => [
                    '*' => ['authorization', 'cookie', 'x-xsrf-token'],
                ],

                // param masking by url_pattern
                'parameters_masking' => [
                    '*' => ['*token*', '*password*'],
                ],
            ],

            'output' => [
                // apply response formatting only for these paths
                'only_paths' => [
                    // 'api/*',
                ],

                // hide all response data for these paths
                'hidden_paths' => [
                    // 'auth/*',
                ],

                // response header masking by url_pattern
                'headers_masking' => [
                    '*' => ['set-cookie'],
                ],

                // response field masking by url_pattern
                'fields_masking' => [
                    '*' => ['*token*', '*password*'],
                ],

                // limit json response size (bytes)
                'max_content_length' => 1048576,
            ],
        ],
    ],
],
```

#### `only_paths`

[](#only_paths)

- `only_paths` (top-level): log only matched request paths.
- `input.only_paths`: apply input masking only to matched paths (others are scrubbed).
- `output.only_paths`: apply output masking only to matched paths (others are scrubbed).

Patterns use Laravel `Str::is` matching.

### JSON response size

[](#json-response-size)

Large JSON responses are skipped and marked with:

```
{"__skipped": "response_too_large"}
```

Masking Rules
-------------

[](#masking-rules)

Masking is pattern-based and configurable.

Masked values keep basic types:

- `bool` -&gt; `false`
- `int` -&gt; `0`
- `float` -&gt; `0.0`
- `string` -&gt; masked string
- arrays/objects -&gt; masked string

Guzzle / HTTP Client tracing
----------------------------

[](#guzzle--http-client-tracing)

You can attach the SLogger handler to Guzzle:

```
new \GuzzleHttp\Client([
    'base_uri' => 'https://url.com',
    'handler'  => app(\SLoggerLaravel\Guzzle\GuzzleHandlerFactory::class)->prepareHandler(
        (new \SLoggerLaravel\RequestPreparer\RequestDataFormatters())
            ->add(
                new \SLoggerLaravel\RequestPreparer\RequestDataFormatter(
                    urlPatterns: ['*'],
                    requestHeaders: ['authorization']
                )
            )
            ->add(
                new \SLoggerLaravel\RequestPreparer\RequestDataFormatter(
                    urlPatterns: ['/api/auth/*', '*sensitive/some/*'],
                    hideAllResponseData: true
                )
            )
    ),
])
```

Dispatchers
-----------

[](#dispatchers-1)

### Queue dispatcher

[](#queue-dispatcher)

Start the dispatcher (spawns queue workers):

```
php artisan slogger:dispatcher:start
```

- Parent traces are sent immediately.
- Child traces are batched (default batch size: 5).
- Orphan traces are sent immediately.
- On shutdown, remaining traces are flushed.

Stop the dispatcher:

```
php artisan slogger:dispatcher:stop
```

### Memory dispatcher

[](#memory-dispatcher)

Stores traces in memory only. Intended for tests/local development.

Storage
-------

[](#storage)

SLogger does not persist traces locally. The only local file is the dispatcher state file in:

```
storage/slogger/dispatcher-state-*.json

```

You may want to ignore the folder:

```
storage/slogger/*
```

Profiling (XHProf)
------------------

[](#profiling-xhprof)

Only for HTTP client tracing.

1. Install extension:

```
pecl install xhprof
```

2. Enable in `php.ini`:

```
[xhprof]
extension=xhprof.so
```

3. Enable:

```
SLOGGER_PROFILING_ENABLED=true
```

Testing
-------

[](#testing)

Run tests:

```
vendor/bin/phpunit
```

The testbench config uses in-memory sqlite and `memory` dispatcher.

Troubleshooting
---------------

[](#troubleshooting)

- Dispatcher not starting: verify `SLOGGER_ENABLED=true` and correct dispatcher name.
- No traces: ensure watchers are enabled and middleware is applied for requests.
- Queue dispatcher not sending: check queue workers and API client URL.
- Socket client errors: verify socket address and backend availability.

License
-------

[](#license)

MIT

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance86

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~19 days

Recently: every ~1 days

Total

24

Last Release

57d ago

Major Versions

v0.1.1 → v1.0.02026-02-23

### Community

Maintainers

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

---

Top Contributors

[![sprust](https://avatars.githubusercontent.com/u/57857525?v=4)](https://github.com/sprust "sprust (166 commits)")

---

Tags

debugginglaravelloggingmonitoringobservabilitytracinglaravelloggingmonitoringdebuggingprofilingtracingobservability

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/slogger-laravel/health.svg)

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

PHPackages © 2026

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