PHPackages                             creitive/monolog-extra-data-processor - 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. creitive/monolog-extra-data-processor

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

creitive/monolog-extra-data-processor
=====================================

A Monolog processor for adding arbitrary logging data

1.0.1(10y ago)648.1k↓45.5%MITPHPPHP &gt;=5.5.0

Since Oct 20Pushed 10y ago13 watchersCompare

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

READMEChangelogDependencies (3)Versions (3)Used By (0)

Monolog Extra Data Processor
============================

[](#monolog-extra-data-processor)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e5ea65a44dea16397f1f8e2ac37aa2ee0156295992aeaf1e489ad65ec6186821/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63726569746976652f6d6f6e6f6c6f672d65787472612d646174612d70726f636573736f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creitive/monolog-extra-data-processor)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/d5ea3fe1b98d39c80a0d0832290f370a421ff3cffa060b97d94e42917a07495f/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f63726569746976652f6d6f6e6f6c6f672d65787472612d646174612d70726f636573736f722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/creitive/monolog-extra-data-processor)[![Total Downloads](https://camo.githubusercontent.com/2706718f04a618f41454b98fd06082a2f72bcb7b360c074be8c38a6ce510180c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63726569746976652f6d6f6e6f6c6f672d65787472612d646174612d70726f636573736f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/creitive/monolog-extra-data-processor)

A processor for [Monolog](https://github.com/Seldaek/monolog) to enable easy addition of arbitrary data into all log entries.

Install
-------

[](#install)

Via Composer

```
$ composer require creitive/monolog-extra-data-processor
```

Usage
-----

[](#usage)

You can do something like this (obviously, the data you pass in depends on your own needs):

```
$extraDataProcessor = new ExtraDataProcessor([
    'environment' => getenv('APP_ENV'),
    'cookies' => $_COOKIES,
    'foo' => 'bar',
]);

/*
 * Assuming `$monolog` is an instance of `\Monolog\Logger`:
 */
$monolog->pushProcessor($extraDataProcessor);
```

That's all! The extra data you've passed will now be logged with all entries, under the `extra` attribute.

If you already have an instance with some data, you can add additional data:

```
$extraDataProcessor = addExtraData([
    'baz' => 'qux',
]);
```

You can also remove extra data by keys:

```
$extraDataProcessor->removeExtraData([
    'foo',
    'baz',
]);
```

And get all currently configured data:

```
$extraData = $extraDataProcessor->getExtraData();
```

What's the point?
-----------------

[](#whats-the-point)

For example, we use this processor class to log the following data (which we find useful):

- Environment (e.g. `local` vs. `staging` vs. `production`)
- Whether PHP is executing as a console command or a web request
- Command-line arguments (if relevant)
- HTTP method
- URL being visited
- Client's IP address
- Referrer
- User agent

Some of this (for example, the web-request stuff) is available via the `Monolog\Processor\WebProcessor` - however, that class seems a bit limited in scope, and it would seem a bit hacky to use it for this purpose.

You could even misuse the `Monolog\Processor\TagProcessor` class to log extra stuff, but it would all be under `extra.tags` instead of just `extra` - and it's still missing the point.

Tips
----

[](#tips)

Since we primarily work with Laravel 5, we have an `App\Log\Configurator` class, which wires the basic logging functionality. It's invoked in `bootstrap/app.php` like this:

```
$app->configureMonologUsing(function(\Monolog\Logger $monolog) use ($app)
{
    $configurator = new \App\Log\Configurator;

    $configurator->configure($monolog, $app);
});
```

The configurator, in turn, pushes the `GitProcessor` (awesome for knowing which exact project commit was being executed when the entry was logged), and the `ExtraDataProcessor` to the passed logger instance. In this step, the `ExtraDataProcessor` is only populated with the current environment, console command check, and command-line arguments - as the rest of the data comes via the HTTP request (which isn't captured yet at this point). We also configure the handlers at this point.

The request data is added later using a service provider, when the app is already booted.

If logging something like input data, be sure to pay attention to privacy issues - for example, don't log `$_POST['password']` from login forms, as this compromises both your users and your system. This is especially true if you're using some kind of cloud-hosted third-party logging service (e.g. Logentries, Loggly, Papertrail, etc.)

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Miloš Levačić](https://github.com/levacic)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

3863d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ccacd35f505d964b1bcf6e6dbed83addb96fbcfda7d07f228d5066fc9771197e?d=identicon)[levacic](/maintainers/levacic)

---

Top Contributors

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

---

Tags

monologprocessor

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/creitive-monolog-extra-data-processor/health.svg)

```
[![Health](https://phpackages.com/badges/creitive-monolog-extra-data-processor/health.svg)](https://phpackages.com/packages/creitive-monolog-extra-data-processor)
```

###  Alternatives

[maxbanton/cwh

AWS CloudWatch Handler for Monolog library

42515.3M27](/packages/maxbanton-cwh)[egeniq/monolog-gdpr

Some Monolog processors that will help in relation to the security requirements under GDPR.

528.7k](/packages/egeniq-monolog-gdpr)[glopgar/monolog-timer-processor

A processor for Monolog that adds timing info to the message contexts

1469.6k](/packages/glopgar-monolog-timer-processor)[alexandre-daubois/monolog-processor-collection

A collection of Monolog processors

1516.6k](/packages/alexandre-daubois-monolog-processor-collection)[bref/monolog-bridge

Monolog formatter optimized for AWS Lambda and CloudWatch

111.2M3](/packages/bref-monolog-bridge)[yzen.dev/mono-processor

This Processor will display in the logs bread crumbs by which you can more quickly and accurately identify the cause of the error.

116.1k](/packages/yzendev-mono-processor)

PHPackages © 2026

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