PHPackages                             techforce/openlogs-monolog - 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. techforce/openlogs-monolog

ActiveLibrary

techforce/openlogs-monolog
==========================

Framework-agnostic Monolog handler that ships logs to an OpenLogs server in batches.

00

Since Jul 22Compare

[ Source](https://github.com/TechForce-US/openlogs-monolog)[ Packagist](https://packagist.org/packages/techforce/openlogs-monolog)[ RSS](/packages/techforce-openlogs-monolog/feed)WikiDiscussions Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

openlogs-monolog
================

[](#openlogs-monolog)

A framework-agnostic [Monolog](https://github.com/Seldaek/monolog) handler that ships logs to an [OpenLogs](https://github.com/jmstewart1127/openlogs) server. It buffers records and delivers them in **batches** to OpenLogs' `POST /api/ingest/batch` endpoint, normalizes every record so a single bad entry can't sink a batch, and **never throws** — on failure it replays records to a fallback handler.

Works anywhere Monolog runs. Using **Laravel**? Prefer the [`techforce/openlogs-laravel`](https://github.com/techforce/openlogs-laravel)bridge, which adds a first-class log channel and queued delivery on top of this handler.

Install
-------

[](#install)

```
composer require techforce/openlogs-monolog
```

Requires PHP 8.1+, `monolog/monolog` ^3, `guzzlehttp/guzzle` ^7.

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

[](#configuration)

The `LoggerFactory` accepts an array with these keys:

KeyRequiredDefaultDescription`url`yes¹—OpenLogs base URL (e.g. `https://logs.example.com`)`api_key`yes¹—Project API key (sent as `X-API-Key`)`channel`no`openlogs`Logger/channel name (becomes the log `channel`)`level`no`Debug`Minimum level (Monolog `Level`, name, or int)`buffer_limit`no`500`Records buffered before an automatic flush`timeout`no`5.0`HTTP timeout in seconds`fallback`nononeA Monolog `HandlerInterface` used when delivery fails`client`nonew GuzzleA Guzzle `ClientInterface` (for reuse/testing)`deliverer`noGuzzle syncA custom `BatchDeliverer` (overrides the default)¹ Required unless you supply your own `deliverer`.

Records buffer in memory and flush when `buffer_limit` is reached and on process shutdown. Keep `buffer_limit` under the server's 1000-entry cap.

Plain PHP
---------

[](#plain-php)

```
use Monolog\Level;
use Monolog\Handler\StreamHandler;
use TechForce\OpenLogs\LoggerFactory;

$logger = (new LoggerFactory())([
    'url'      => getenv('OPENLOGS_URL'),
    'api_key'  => getenv('OPENLOGS_API_KEY'),
    'channel'  => 'my-app',
    'fallback' => new StreamHandler('php://stderr', Level::Warning),
]);

$logger->info('User signed up', ['user_id' => 42]);
// buffered — delivered as a batch on shutdown (or when the buffer fills)
```

Symfony
-------

[](#symfony)

Register the logger as a service and reference the handler from your Monolog config. In `config/services.yaml`:

```
services:
    TechForce\OpenLogs\LoggerFactory: ~

    openlogs.logger:
        class: Monolog\Logger
        factory: ['@TechForce\OpenLogs\LoggerFactory', '__invoke']
        arguments:
            - url: '%env(OPENLOGS_URL)%'
              api_key: '%env(OPENLOGS_API_KEY)%'
              channel: '%kernel.environment%'
```

Then route a Monolog channel/handler to it, or pull the OpenLogs handler off that logger and reference it from `monolog.yaml`. A `StreamHandler` to `var/log` makes a good `fallback`.

Laravel
-------

[](#laravel)

Use the [`techforce/openlogs-laravel`](https://github.com/techforce/openlogs-laravel)bridge — it registers an `openlogs` log channel, publishes config, and adds opt-in queued delivery on a dedicated queue.

How it works
------------

[](#how-it-works)

```
Log call → BufferHandler → OpenLogsHandler::handleBatch()
                                 │  normalize records → wire entries
                                 ▼
                          BatchDeliverer::deliver(entries, records)
                                 │
                    SyncGuzzleDeliverer → POST /api/ingest/batch
                                 │  on failure (network / non-201):
                                 ▼  replay original records → fallback handler

```

The `BatchDeliverer` interface is the extension seam: implement it to change how batches are delivered (for example, the Laravel bridge's queued deliverer).

License
-------

[](#license)

MIT

###  Health Score

9

—

LowBetter than 0% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a0496b0e3fc2a00564f53a8b9723d17b926e64b4dded05fb885c10a5310d246?d=identicon)[Jmstewart1127](/maintainers/Jmstewart1127)

### Embed Badge

![Health badge](/badges/techforce-openlogs-monolog/health.svg)

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

PHPackages © 2026

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