PHPackages                             macbre/monolog-utils - 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. macbre/monolog-utils

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

macbre/monolog-utils
====================

Additional formatters and processors for Monolog

3.1.0(1y ago)012.5k—0%1[2 PRs](https://github.com/macbre/monolog-utils/pulls)1MITPHPPHP ^8.1CI passing

Since Dec 12Pushed 3mo agoCompare

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

READMEChangelog (4)Dependencies (2)Versions (8)Used By (1)

monolog-utils
=============

[](#monolog-utils)

[![Latest Stable Version](https://camo.githubusercontent.com/9328f5dbcc66522122e516dc02b11bea7df000ae1bfffa7d6832d5bbfb00c0b9/687474703a2f2f706f7365722e707567782e6f72672f6d61636272652f6d6f6e6f6c6f672d7574696c732f76)](https://packagist.org/packages/macbre/monolog-utils)[![Coverage Status](https://camo.githubusercontent.com/661a30eb0003277dae87458259e1f0ecab30a9688d237004556b3257989de3ff/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d61636272652f6d6f6e6f6c6f672d7574696c732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/macbre/monolog-utils?branch=master)

Additional formatters and processors for Monolog 3.x. This package requires PHP 8.1+.

`ExceptionProcessor`
--------------------

[](#exceptionprocessor)

Allows you to pass an `Exception` instance as a part of `$context` - it will be automatically expanded to log exception class, message, code and a backtrace

```
try {
	// do something
}
catch (NastyException $ex) {
	$logger->error('Something bad happended', [
		'exception' => $ex
	]);
}
```

`exception` field will be expanded to something similar to:

```
{
	"context": {
		"exception": {
			"class": "NastyException",
			"message": "Things went wrong",
			"code": 42,
			"trace": [
				"/home/macbre/app/Foo.class.php:979",
				"/home/macbre/app/App.class.php:29",
				"/home/macbre/app/index.php:18"
			]
		}
	}
}
```

`RequestIdProcessor`
--------------------

[](#requestidprocessor)

Automatically generates a unique, per request ID that is sent with every message log as `request_id` field in `$extra`.

`JsonFormatter`
---------------

[](#jsonformatter)

JSON log formatter for elastic / Kibana.

An example entry:

```
$logger->error('Foo Bar', [
	'size' => 42
]);
```

```
{
	"@timestamp": "2023-04-18T08:25:23.123456+00:00",
	"message": "Foo Bar",
	"context": {
		"size": 42
	},
	"extra": {
		"request_id": "566c04c2f22693.59900054"
	},
	"severity": "error",
	"channel": "my.app",
	"source_host": "my.server.net"
}
```

Example
=======

[](#example)

```
$logger = new Monolog\Logger('my.app');

$logger->pushProcessor(new Macbre\Logger\Processors\ExceptionProcessor());
$logger->pushProcessor(new Macbre\Logger\Processors\RequestIdProcessor());

// Syslog and JSON formatter for elastic / Kibana
$syslog = new Monolog\Handler\SyslogUdpHandler('127.0.0.1', 514, LOG_USER, Monolog\Logger::INFO);
$syslog->setFormatter(new Macbre\Logger\Formatters\JsonFormatter());
$logger->pushHandler($syslog);

// and now let's use the logger...
$logger->error('Foo Bar', [
	'exception' => new Exception('An error', 123),
	'size' => 42
]);
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance60

Regular maintenance activity

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~798 days

Total

5

Last Release

616d ago

Major Versions

1.0.0 → 2.02020-05-28

2.1 → 3.0.02023-04-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1929317?v=4)[Maciej Brencz](/maintainers/macbre)[@macbre](https://github.com/macbre)

---

Top Contributors

[![macbre](https://avatars.githubusercontent.com/u/1929317?v=4)](https://github.com/macbre "macbre (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")

---

Tags

loggingmonolog-handlermonolog-processorphp8loglogging

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/macbre-monolog-utils/health.svg)

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

###  Alternatives

[symfony/monolog-bundle

Symfony MonologBundle

2.9k249.1M1.6k](/packages/symfony-monolog-bundle)[inpsyde/wonolog

Monolog-based logging package for WordPress.

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

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.6M70](/packages/amphp-log)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/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)
