PHPackages                             spazzmarticus/monolog-batchstreamhandler - 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. spazzmarticus/monolog-batchstreamhandler

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

spazzmarticus/monolog-batchstreamhandler
========================================

Pushes a batch of records to a stream at once.

3.0.0(3y ago)218.9k↓50%MITPHPPHP &gt;=8.1

Since Nov 9Pushed 3y ago1 watchersCompare

[ Source](https://github.com/SpazzMarticus/monolog-batchstreamhandler)[ Packagist](https://packagist.org/packages/spazzmarticus/monolog-batchstreamhandler)[ Docs](https://github.com/SpazzMarticus/monolog-batchstreamhandler)[ RSS](/packages/spazzmarticus-monolog-batchstreamhandler/feed)WikiDiscussions master Synced 1mo ago

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

BatchStreamHandler
==================

[](#batchstreamhandler)

A [Monolog](https://github.com/Seldaek/monolog) handler that takes a batch of records and pushes them to a stream **at once**.

(Use ^2.0 or Monolog ^2.0 and ^1.0 for Monolog ^1.x)

Why
---

[](#why)

When logging calls to webservers I like all log records of one call grouped together. I changed the default `StreamHandler` to handle only batches of records (`handleBatch`) and write them to the stream at once - voilà the `BatchStreamHandler`.

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

[](#installation)

Install with

```
composer require spazzmarticus/monolog-batchstreamhandler

```

Usage
-----

[](#usage)

```
use SpazzMarticus\BatchStreamHandler\BatchStreamHandler;
use Monolog\Handler\BufferHandler;
use Monolog\Logger;

$batchStreamHandler = new BatchStreamHandler('supsi-looking.log');

//Optional - Envelop the records with head and foot lines
$batchStreamHandler->pushHeadLine('-------');
$batchStreamHandler->pushFootLine('=======');

$bufferHandler = new BufferHandler($batchStreamHandler);

$logger = new Logger('supsi');
$logger->pushHandler($bufferHandler);

//PewPew - Do your stuff here
```

`StreamHandler` vs `BatchStreamHandler`
---------------------------------------

[](#streamhandler-vs-batchstreamhandler)

The default `StreamHandler` pushes each record to the stream immediatly. Even when put after a BufferHandler (which buffers records until `flush()` is called) each record is processed and written to the stream seperatly.

Let's assume there are 3 parallel calls to the webserver `A`, `B`, `C`

```
  ------------------- Time ------------------->
A --[Debug]------[Notice]--------[Error]---|
B -[Warning][Warning]---------------|
C -----[Notice][Error]------------------------|

```

The log looks something like:

```
Warning
Debug
Notice
Warning
Error
Notice
Error

```

And that makes it hard to look at what happend at a specific calls.

With the `BatchStreamHandler` the log looks something like:

```
Warning
Warning
Debug
Notice
Error
Notice
Error

```

Which is still not superb, so I added enveloping with head and foot lines.

Now this looks like a log I can work with:

```
-------
Warning
Warning
=======
-------
Debug
Notice
Error
=======
-------
Notice
Error
=======

```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity75

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

Total

4

Last Release

1342d ago

Major Versions

1.1.0 → 2.0.02020-02-04

2.0.0 → 3.0.02022-09-14

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

2.0.0PHP ^7.2

3.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7671dde90009502e4cdb4576dba1a34d1db8aecd12a2eed1dbbf72b7d27a8e87?d=identicon)[SpazzMarticus](/maintainers/SpazzMarticus)

---

Top Contributors

[![SpazzMarticus](https://avatars.githubusercontent.com/u/5716457?v=4)](https://github.com/SpazzMarticus "SpazzMarticus (18 commits)")

---

Tags

batchmonologlogpsr-3logging

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/spazzmarticus-monolog-batchstreamhandler/health.svg)

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

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k964.9M7.0k](/packages/monolog-monolog)[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[apix/log

Minimalist, thin and fast PSR-3 compliant (multi-bucket) logger.

511.0M18](/packages/apix-log)[nvanheuverzwijn/monolog-logdna

Mezmo/Logdna handler for Monolog

21231.3k2](/packages/nvanheuverzwijn-monolog-logdna)[elastic/ecs-logging

Format and enrich your log files in the elastic common schema

21907.5k1](/packages/elastic-ecs-logging)

PHPackages © 2026

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