PHPackages                             ricardoboss/php-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. ricardoboss/php-seq

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

ricardoboss/php-seq
===================

Implements a PHP client for the Seq (by Datalust) HTTP ingestion API

v1.1.1(2y ago)031MITPHPPHP ^8.2

Since May 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ricardoboss/php-seq)[ Packagist](https://packagist.org/packages/ricardoboss/php-seq)[ RSS](/packages/ricardoboss-php-seq/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

[![Unit Tests](https://github.com/ricardoboss/php-seq/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/ricardoboss/php-seq/actions/workflows/unit-tests.yml)[![](https://camo.githubusercontent.com/06196bc95ed46b925fa39f359312c64e944c9687e7e1082a7425c69badadca7d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7269636172646f626f73732f7068702d736571)](https://packagist.org/packages/ricardoboss/php-seq)

php-seq
=======

[](#php-seq)

A PHP library for [Seq](https://datalust.co/seq) HTTP ingestion.

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

[](#installation)

```
composer require ricardoboss/php-seq

```

Usage
-----

[](#usage)

```
// 0. gather dependencies (preferably using dependency injection)
$httpClient = getPsr18Client(); // PSR-18 (HTTP Client)
$requestFactory = getPsr17RequestFactory(); // PSR-17 (HTTP Factories)
$streamFactory = getPsr17StreamFactory(); // PSR-17 (HTTP Factories)

// 1. create the Seq client
$clientConfig = new SeqHttpClientConfiguration("https://my-seq-host:5341/api/events/raw", "my-api-key");
$seqClient = new SeqHttpClient($clientConfig, $httpClient, $requestFactory, $streamFactory);

// 2. create the logger
$loggerConfig = new SeqLoggerConfiguration();
$logger = new SeqLogger($loggerConfig, $seqClient);

// 3. start logging!
$logger->send(SeqEvent::info("Hello from PHP!"));
// or
$logger->info("Hello via PSR-3!"); // or $logger->log(\Psr\Log\LogLevel::INFO, "...");

// using message templates:
$logger->info('This is PHP {PhpVersion}', ['PhpVersion' => PHP_VERSION]);

// (optional) 4. force sending all buffered events
$logger->flush();
```

> **Note**
>
> All events get flushed automatically when the loggers `__destruct` method is called (i.e. at latest when the runtime shuts down).

You can use the example project in the [`example`](./example) folder to try different things out. It uses [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/guzzle) as its PSR implementations.

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

[](#configuration)

The configuration is split up between the actual client, sending the requests and the logger gathering events and forwarding them to the client. This makes it possible to create multiple loggers with different contexts/minimum log levels using the same client. Also, it enables us to implement new clients for other interfaces in the future (see “Future Scope” below).

### `SeqHttpClientConfiguration`

[](#seqhttpclientconfiguration)

ParameterTypeDefaultDescription`$endpoint``string`-The endpoint to use. Must not be empty. Usually has the form ""`$apiKey``string|null``null`If your Seq instance requires authentication, you need to provide your API key here. If given, it must not be empty.`$maxRetries``int``3`The number of tries before throwing an exception if sending the events fails. Exceptions implementing `\Psr\Http\Client\NetworkExceptionInterface` bypass this limit and are immediately rethrown.### `SeqLoggerConfiguration`

[](#seqloggerconfiguration)

ParameterTypeDefaultDescription`$backlogLimit``int``10`The amount of events to collect before sending a batch to the server. You can explicitly flush all buffered events using the `flush` method.`$globalContext``array|null``null`A key-value list that gets attached to all events logged using this logger.Advanced usage
--------------

[](#advanced-usage)

### Message templates &amp; context

[](#message-templates--context)

Seq supports the [message templates](https://messagetemplates.org/) syntax. You can use it too using the context parameter:

```
$username = "EarlyBird91";

// Will log "Created EarlyBird91 user" to Seq with the "username" attribute set to "EarlyBird91"
$logger->info("Created {username} user", ['username' => $username]);
```

> **Note**
>
> The context values will be converted to strings. If they aren't scalar or `Stringable` objects, they are encoded using `json_encode`.

### Custom Seq events

[](#custom-seq-events)

Seq uses the [CLEF format](https://clef-json.org/) for HTTP ingestion, which is used by this library. For your convenience, you can directly access all the properties of the CLEF format using the `SeqEvent` class.

Just create a new instance and send it using the `SeqLogger` or encode it using `json_encode`:

```
$event = new SeqEvent(
    new DateTimeImmutable(),
    "message",
    "messageTemplate",
    "level",
    new Exception("exception"),
    123,
    ['attribute' => 'rendered'],
    ['tag' => 'value'],
);

$logger->send($event);
// or
echo json_encode($event); // {"@t":"2023-05-16T12:00:01.123456+00:00","@mt":"messageTemplate",...}
```

Note that you still need to validate the event yourself if you create it that way. You can check the requirements from Seq here: [Reified properties](https://docs.datalust.co/docs/posting-raw-events#reified-properties)

Escaping of user properties using `@` is done automatically when encoding the event to JSON.

### Minimum log level

[](#minimum-log-level)

You can specify the minimum log level a logger will buffer and send to Seq using the `$minimumLogLevel` constructor parameter of the `SeqLoggerConfiguration` class:

```
$config = new SeqLoggerConfiguration(minimumLogLevel: SeqLogLevel::Warning);
```

This will allow only `Warning` or more critical events to be sent to Seq (like `Error` and `Fatal`).

You can also adjust the minimum log level of the logger at runtime:

```
$previousLogLevel = $logger->getMinimumLogLevel();

$logger->setMinimumLogLevel(SeqLogLevel::Information);
```

### Dynamic Level Control

[](#dynamic-level-control)

Seq supports a scheme called "Dynamic Level Control", which allows the client to adjust its minimum log level based on what is configured for its API key.

`php-seq` also supports this and will adjust the minimum log level of each logger based on what Seq responds.

You can read up on Dynamic Level Control [here on Seq's website](https://docs.datalust.co/docs/using-serilog#dynamic-level-control) or in [this brief blog post](https://nblumhardt.com/2016/02/remote-level-control-in-serilog-using-seq/) by Nicholos Blumhardt.

Error handling
--------------

[](#error-handling)

All exceptions thrown by this library implement the `\RicardBoss\PhpSeq\Contract\SeqException` interface. This makes it easy to catch any exception wrapped by this library.

Future Scope
------------

[](#future-scope)

The aim for this library is to provide simple logging for Seq in PHP and stay compatible with current PHP and Seq versions.

A possible addition for this library could be to use GELF instead of HTTP using the `sockets` extension, but this is not planned for now.

Contributing
------------

[](#contributing)

Contributions in all forms are welcome! If you are missing a specific feature or something isn't working as expected, please create an issue on GitHub: [create issue](https://github.com/ricardoboss/php-seq/issues/new).

If you can, you are encouraged to create a pull request. Please make sure you add tests for the functionality you add/change and make sure they pass.

License
-------

[](#license)

This project is licensed under the MIT license. For more information, see [License](./LICENSE.md).

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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

Total

4

Last Release

1065d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ea436f1f084470f9d75ca0fde95e2418ba03d560bc4e20e03171648c123fa80?d=identicon)[ricardoboss](/maintainers/ricardoboss)

---

Top Contributors

[![ricardoboss](https://avatars.githubusercontent.com/u/6266356?v=4)](https://github.com/ricardoboss "ricardoboss (57 commits)")

---

Tags

datalustloggingphppsr-3seqloggingseqDatalust

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ricardoboss-php-seq/health.svg)

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[open-telemetry/api

API for OpenTelemetry PHP.

1933.0M214](/packages/open-telemetry-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[markrogoyski/simplelog-php

Powerful PSR-3 logging. So easy, it's simple.

2818.1k4](/packages/markrogoyski-simplelog-php)

PHPackages © 2026

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