PHPackages                             pablo1gustavo/monolog-seq - 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. pablo1gustavo/monolog-seq

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

pablo1gustavo/monolog-seq
=========================

Integrates Monolog with Seq using HTTP ingestion, enabling structured event logging to a centralized Seq server for enhanced log management.

v1.2.0(2mo ago)72.0k↑221.4%MITPHPPHP &gt;=8.1CI failing

Since Mar 2Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Pablo1Gustavo/monolog-seq)[ Packagist](https://packagist.org/packages/pablo1gustavo/monolog-seq)[ RSS](/packages/pablo1gustavo-monolog-seq/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (2)Dependencies (6)Versions (6)Used By (0)

Monolog Seq
===========

[](#monolog-seq)

 [![](https://camo.githubusercontent.com/1465fb6b7fbdd7edc0132560a71ff4866d046b467ccfa9cec721d56e7e076491/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f332f33312f5765627973746865725f32303136303432335f2d5f456c65706870616e742e7376672f3338343070782d5765627973746865725f32303136303432335f2d5f456c65706870616e742e7376672e706e67)](https://camo.githubusercontent.com/1465fb6b7fbdd7edc0132560a71ff4866d046b467ccfa9cec721d56e7e076491/68747470733a2f2f75706c6f61642e77696b696d656469612e6f72672f77696b6970656469612f636f6d6d6f6e732f7468756d622f332f33312f5765627973746865725f32303136303432335f2d5f456c65706870616e742e7376672f3338343070782d5765627973746865725f32303136303432335f2d5f456c65706870616e742e7376672e706e67) [![](https://camo.githubusercontent.com/46c544f142c2647da4f7c6708a37552c5a3042d7944141ee8a3f51ca395dc75c/68747470733a2f2f646174616c7573742e636f2f6173736574732f7365712d6c6f676f2d6c696768742e737667)](https://camo.githubusercontent.com/46c544f142c2647da4f7c6708a37552c5a3042d7944141ee8a3f51ca395dc75c/68747470733a2f2f646174616c7573742e636f2f6173736574732f7365712d6c6f676f2d6c696768742e737667)

Integrates PHP Monolog with Seq using HTTP ingestion, enabling structured event logging to a centralized Seq server for enhanced log management.

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

[](#installation)

```
composer require pablo1gustavo/monolog-seq
```

Usage
-----

[](#usage)

This package automatically formats log records as [CLEF](https://clef-json.org/) (Compact Log Event Format) and sends them to Seq via HTTP. The fields `@t`, `@m`/`@mt`, `@l`, and `@x` are set automatically from the log record.

For more details, refer to the [official Seq documentation](https://docs.datalust.co/docs/posting-raw-events).

### Vanilla PHP

[](#vanilla-php)

You can find a runnable example in [`example.php`](example.php).

```
use Monolog\Logger;
use Pablo1Gustavo\MonologSeq\Handler\SeqHandler;

$logger = new Logger('app');
$logger->pushHandler(new SeqHandler(
    url: 'http://localhost:5341/ingest/clef',
    apiKey: 'your-api-key',
));

$logger->info("hello my name is {name}", ['name' => 'pablo']);
$logger->warning('warn message', ['abc' => '123', 'def' => [1, 2, 3]]);
$logger->error('something failed', ['exception' => new Exception('error')]);
$logger->debug('debug message', ['date' => new DateTime('2002-01-13')]);
$logger->info('User logged in', ['@i' => 0xABCD1234, 'userId' => 42]);
```

### Laravel

[](#laravel)

Laravel allows configuring custom Monolog handlers within `config/logging.php`. See [Laravel Logging - Creating Monolog Handler Channels](https://laravel.com/docs/13.x/logging#creating-monolog-handler-channels) for details.

```
'seq' => [
    'driver'    => 'monolog',
    'level'     => env('LOG_LEVEL', 'debug'),
    'handler'   => \Pablo1Gustavo\MonologSeq\Handler\SeqHandler::class,
    'formatter' => \Pablo1Gustavo\MonologSeq\Formatter\SeqJsonFormatter::class,
    'with' => [
        'url'    => env('SEQ_URL'),
        'apiKey' => env('SEQ_API_KEY'),
    ],
],
```

> The `formatter` key is required. Without it, Laravel applies its default formatter, which produces plain text instead of CLEF.

### Symfony

[](#symfony)

See [How to Define a Custom Logging Handler](https://symfony.com/doc/current/logging/handlers.html) for details.

Register both the handler and the formatter as services in `config/services.yaml`:

```
services:
    Pablo1Gustavo\MonologSeq\Formatter\SeqJsonFormatter: ~

    Pablo1Gustavo\MonologSeq\Handler\SeqHandler:
        arguments:
            $url: '%env(SEQ_URL)%'
            $apiKey: '%env(SEQ_API_KEY)%'
```

Then reference them in `config/packages/monolog.yaml`:

```
monolog:
    handlers:
        seq:
            type:      service
            id:        Pablo1Gustavo\MonologSeq\Handler\SeqHandler
            formatter: Pablo1Gustavo\MonologSeq\Formatter\SeqJsonFormatter
```

> The `formatter` option is required. Without it, Symfony's MonologBundle applies `LineFormatter` by default, which produces plain text instead of CLEF.

Retry
-----

[](#retry)

`SeqHandler` automatically retries failed deliveries using an exponential-free (immediate) retry strategy. By default it retries up to **3 times** on:

- **Connection errors** — DNS failure, connection refused, timeout, SSL errors
- **HTTP 503 Service Unavailable** — the only HTTP status that explicitly signals transient unavailability

All other failures (4xx, 500, 502, 504…) are not retried.

When all retries are exhausted, a `SeqDeliveryException` is thrown with the original cause attached as `$previous`.

```
new SeqHandler(
    url: 'http://localhost:5341/ingest/clef',
    apiKey: 'your-api-key',
    maxRetries: 5, // default: 3 — set to 0 to disable retries
);
```

Batch Ingestion
---------------

[](#batch-ingestion)

By default, each log record is sent as a separate HTTP request. For better performance, wrap `SeqHandler` with Monolog's `BufferHandler` to accumulate records and flush them in a single request at the end of the process:

```
use Monolog\Handler\BufferHandler;
use Pablo1Gustavo\MonologSeq\Handler\SeqHandler;

$logger->pushHandler(
    new BufferHandler(
        new SeqHandler(
            url: 'http://localhost:5341/ingest/clef',
            apiKey: 'your-api-key',
        )
    )
);
```

The `BufferHandler` automatically flushes at the end of the request via `register_shutdown_function()`.

CLEF Fields via Context
-----------------------

[](#clef-fields-via-context)

Any [CLEF property](https://clef-json.org/) passed in the log context is promoted to a top-level field in the event. This includes tracing, event identity, and custom overrides:

```
// Event ID — used by Seq to group and deduplicate events
$logger->info('User logged in', [
    '@i' => 0xABCD1234,
    'userId' => 42,
]);
// Distributed tracing (OpenTelemetry)
$logger->info('Incoming request', [
    '@tr' => $traceId,
    '@sp' => $spanId,
]);
// Override formatter defaults
$logger->info('Custom timestamp', [
    '@t' => '2020-01-01T00:00:00Z',
]);
```

Supported CLEF fields: `@i` (event ID), `@tr` (trace ID), `@sp` (span ID), `@ps` (parent span ID), `@st` (span start), `@sk` (span kind), `@sc` (instrumentation scope), `@ra` (resource attributes).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance87

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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 ~141 days

Total

4

Last Release

66d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34045117?v=4)[Pablo Gustavo](/maintainers/pablo1gustavo)[@Pablo1Gustavo](https://github.com/Pablo1Gustavo)

---

Top Contributors

[![Pablo1Gustavo](https://avatars.githubusercontent.com/u/34045117?v=4)](https://github.com/Pablo1Gustavo "Pablo1Gustavo (22 commits)")

---

Tags

logloggingintegrationmonologseqDatalust

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/pablo1gustavo-monolog-seq/health.svg)

```
[![Health](https://phpackages.com/badges/pablo1gustavo-monolog-seq/health.svg)](https://phpackages.com/packages/pablo1gustavo-monolog-seq)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[lefuturiste/monolog-discord-handler

A simple monolog handler for support Discord webhooks

34118.3k4](/packages/lefuturiste-monolog-discord-handler)[inpsyde/wonolog

Monolog-based logging package for WordPress.

184637.3k7](/packages/inpsyde-wonolog)[logtail/monolog-logtail

Logtail handler for Monolog

243.6M3](/packages/logtail-monolog-logtail)[inpsyde/logzio-monolog

Logz.io integration for Monolog

191.2M1](/packages/inpsyde-logzio-monolog)

PHPackages © 2026

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