PHPackages                             giovanne-oliveira/newrelic-monolog-enricher - 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. giovanne-oliveira/newrelic-monolog-enricher

ActiveLibrary

giovanne-oliveira/newrelic-monolog-enricher
===========================================

Monolog components to enable New Relic Logs

2.1.0(5mo ago)0166↓33.3%Apache-2.0PHPPHP &gt;=8.1CI passing

Since Nov 22Pushed 5mo agoCompare

[ Source](https://github.com/giovanne-oliveira/newrelic-monolog-logenricher-php)[ Packagist](https://packagist.org/packages/giovanne-oliveira/newrelic-monolog-enricher)[ RSS](/packages/giovanne-oliveira-newrelic-monolog-enricher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Monolog components to enable New Relic logs
===========================================

[](#monolog-components-to-enable-new-relic-logs)

[![Latest Stable Version](https://camo.githubusercontent.com/cd275800c5ac3d92984ae24008449238bd787a9c48ed385fae9b03b5652bf5f2/68747470733a2f2f706f7365722e707567782e6f72672f67696f76616e6e652d6f6c6976656972612f6e657772656c69632d6d6f6e6f6c6f672d656e7269636865722f76657273696f6e)](https://packagist.org/packages/giovanne-oliveira/newrelic-monolog-enricher) [![Latest Unstable Version](https://camo.githubusercontent.com/e4a4915b841a16308ceaea2936813b5d23c53455a704d4e43212c26a7cb06b02/68747470733a2f2f706f7365722e707567782e6f72672f67696f76616e6e652d6f6c6976656972612f6e657772656c69632d6d6f6e6f6c6f672d656e7269636865722f762f756e737461626c65)](//packagist.org/packages/giovanne-oliveira/newrelic-monolog-enricher) [![License](https://camo.githubusercontent.com/c978fa187fb2cb15fb2abb9af8b40f44601e050f7b20a8bced32ca6face83da0/68747470733a2f2f706f7365722e707567782e6f72672f67696f76616e6e652d6f6c6976656972612f6e657772656c69632d6d6f6e6f6c6f672d656e7269636865722f6c6963656e7365)](https://packagist.org/packages/giovanne-oliveira/newrelic-monolog-enricher)

This package provides the components required to integrate a PHP application using [Monolog](https://github.com/Seldaek/monolog) with [New Relic Logs](https://newrelic.com/products/logs).

Note

This is a fork of the original [newrelic/newrelic-monolog-logenricher-php](https://github.com/newrelic/newrelic-monolog-logenricher-php) package, updated to support Monolog 3 and PHP 8.1+.

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

[](#installation)

### Components

[](#components)

Three components are provided:

1. A [`Handler`](https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#core-concepts), which delivers log records directly from Monolog to New Relic Logs.
2. A [`Processor`](https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#using-processors). This can be used in conjunction with the [New Relic PHP agent](https://docs.newrelic.com/docs/agents/php-agent) to decorate log records with [linking metadata](https://docs.newrelic.com/docs/agents/php-agent/php-agent-api/newrelicgetlinkingmetadata), which allows you to use [logs-in-context](https://docs.newrelic.com/docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-apm-agents)to correlate log records with related data across the New Relic platform.
3. A [`Formatter`](https://github.com/Seldaek/monolog/blob/master/doc/01-usage.md#customizing-the-log-format), which extends the [`JsonFormatter`](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/JsonFormatter.php)provided by Monolog to take the decorated log records from the `Processor`and output them with the [simplified JSON body structure expected by New Relic Logs](https://docs.newrelic.com/docs/logs/new-relic-logs/log-api/introduction-log-api#json-content)and [its supported plugins](https://docs.newrelic.com/docs/logs/new-relic-logs/enable-logs/enable-new-relic-logs#enable-logs).

Please see [Getting Started](#getting-started) below for more detail on how to integrate these components with your application.

### Requirements

[](#requirements)

- [Monolog](https://github.com/Seldaek/monolog), version 3.
- PHP 8.1 or later.

To use the `Handler`, you will also need the following:

- PHP's [curl extension](https://php.net/curl).

To enable [logs-in-context](https://docs.newrelic.com/docs/logs/new-relic-logs/enable-logs-context/enable-logs-context-apm-agents)functionality, you will also need:

- The [New Relic PHP agent](https://docs.newrelic.com/docs/agents/php-agent), version 9.3 or later.

### Install

[](#install)

This package is available [on Packagist](https://packagist.org/packages/giovanne-oliveira/newrelic-monolog-enricher), and should be installed using [Composer](https://getcomposer.org):

```
composer require giovanne-oliveira/newrelic-monolog-enricher
```

Getting Started
---------------

[](#getting-started)

### Sending logs directly to New Relic Logs

[](#sending-logs-directly-to-new-relic-logs)

The simplest way to use this package is to use the `Processor` and `Handler` to send data directly to New Relic Logs:

```
