PHPackages                             nagi/laravel-newrelic-log-api - 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. nagi/laravel-newrelic-log-api

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

nagi/laravel-newrelic-log-api
=============================

This is my package laravel-newrelic-log-api

v1.0.6(9mo ago)2499MITPHPPHP ^8.2CI passing

Since Sep 9Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/nagi1/laravel-newrelic-log-api)[ Packagist](https://packagist.org/packages/nagi/laravel-newrelic-log-api)[ Docs](https://github.com/nagi1/laravel-newrelic-log-api)[ GitHub Sponsors](https://github.com/nagi1)[ RSS](/packages/nagi-laravel-newrelic-log-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (9)Versions (9)Used By (0)

New Relic Log API for Laravel
=============================

[](#new-relic-log-api-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1f69116761c102eef6c6ef7eddd6ff602870bd6d2ea63722818b92fac4a15915/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6167692f6c61726176656c2d6e657772656c69632d6c6f672d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nagi/laravel-newrelic-log-api)[![GitHub Tests Action Status](https://camo.githubusercontent.com/2d9e576da2cbfc71586ec3f32b99792fd03b8b17630a937a99e57e6152a9c6dc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e616769312f6c61726176656c2d6e657772656c69632d6c6f672d6170692f72756e2d74657374732e796d6c3f6272616e63683d646576266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/nagi1/laravel-newrelic-log-api/actions?query=workflow%3Arun-tests+branch%3Adev)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b102d3918a651b28e8df9d814e070d8a9a2079e3b1566cefad11e85ac538714a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6e616769312f6c61726176656c2d6e657772656c69632d6c6f672d6170692f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d646576266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/nagi1/laravel-newrelic-log-api/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Adev)[![Total Downloads](https://camo.githubusercontent.com/876f52cfb90b82c24caeefeb8b5a9c320abc91648dce833636fa0aa2a2337d7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6e6167692f6c61726176656c2d6e657772656c69632d6c6f672d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/nagi/laravel-newrelic-log-api)

Integrate New Relic Log API with Laravel your laravel application. It mainly utilizing queuse behind the scene to send the logs to New Relic API. so make sure you have queue worker running.

```
    // in loggin.php
    'stack' => [
                'driver' => 'stack',
                'channels' => ['single', 'newrelic-log-api'],
                'ignore_exceptions' => false,
            ],

        //...
        'newrelic-log-api' => [
            'driver' => 'monolog',
            'handler' => \Nagi\LaravelNewrelicLogApi\LaravelNewrelicLogApi::logHandler(),
            'level' => 'debug',
        ],
```

```
logger('newrelic-log-api')->info('Hey Mom!');

// or if you are using stack

logger()->info('Hey Mom!');
```

Support Me
----------

[](#support-me)

Does your business depend on my contributions? Reach out and support me on [PayPal](https://www.paypal.com/paypalme/nagix1). All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

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

[](#installation)

You can install the package via composer:

```
composer require nagi/laravel-newrelic-log-api
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-newrelic-log-api-config"
```

This is the contents of the published config file:

```
return [
    'enabled' => env('NEWRELIC_ENABLED', false),

    /**
     * New Relic API key or License key
     *
     * @see https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#setup
     */
    'api_key' => env('NEWRELIC_API_KEY'),

    /**
     * The base URL for the new relic log API
     *
     * @see https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#endpoint
     */
    'base_url' => env('NEWRELIC_BASE_URL', 'https://log-api.eu.newrelic.com'),

    /**
     * The minimum logging level at which this handler will be triggered
     */
    'level' => env('NEWRELIC_LEVEL', 'debug'),

    /**
     * Retry sending the log to New Relic API
     */
    'retry' => env('NEWRELIC_RETRY', 3),

    /**
     * Delay between retries in milliseconds
     */
    'retry_delay' => env('NEWRELIC_RETRY_DELAY', 1000),

    /**
     * Queue name to use for sending logs to New Relic API
     */
    'queue' => env('NEWRELIC_QUEUE', 'default'),

    /**
     * Log handler to use for sending logs to New Relic API
     */
    'log_handler' => \Nagi\LaravelNewrelicLogApi\NewrelicLogHandler::class,
];
```

**🚨 Make sure that you have queue worker configured.**

Usage
-----

[](#usage)

### Get your newrelic License/API

[](#get-your-newrelic-licenseapi)

### Add env values in your .env

[](#add-env-values-in-your-env)

```
NEWRELIC_ENABLED=true
NEWRELIC_API_KEY=

# if your account is not EU change the baseurl
# https://log-api.newrelic.com/log/v1
NEWRELIC_BASE_URL=https://log-api.eu.newrelic.com

```

### Add new relic channel to your config

[](#add-new-relic-channel-to-your-config)

In your `logging.php` add `new-relic-log-api` channel

```
        'newrelic-log-api' => [
            'driver' => 'monolog',
            'handler' => \Nagi\LaravelNewrelicLogApi\LaravelNewrelicLogApi::logHandler(),
            'level' => env('NEWRELIC_LEVEL', 'debug')
        ],
```

### Add it to your logging stack

[](#add-it-to-your-logging-stack)

in `logging.php`

```
    'stack' => [
                'driver' => 'stack',
                'channels' => ['single', 'newrelic-log-api'],
                'ignore_exceptions' => false,
            ],
```

Listen to the event
-------------------

[](#listen-to-the-event)

If you are intrested in geting the response from the New Relic API you can listen to the event `NewrelicLogApiResponseEvent` It will have the status and the response from the API.

```
    protected $listen = [
        NewrelicLogApiResponseEvent::class => [
            NewrelicLogApiResponseListener::class,
        ],
    ];
```

Note on context log (attributes)
--------------------------------

[](#note-on-context-log-attributes)

When sending one of the following attributes in the context it will be prefixed with `attr_` to avoid overriding the whole message.

See: [New Relic Log API](https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/#attributes)

Extending
---------

[](#extending)

All of the classes in this package are loaded via Laravel's service container meaning you can easily replace them with your own implementation. On Your Own Risk.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ahmed Nagi](https://github.com/nagi1)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance55

Moderate activity, may be stable

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Recently: every ~78 days

Total

7

Last Release

297d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laravelAhmed Nagilaravel-newrelic-log-api

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/nagi-laravel-newrelic-log-api/health.svg)

```
[![Health](https://phpackages.com/badges/nagi-laravel-newrelic-log-api/health.svg)](https://phpackages.com/packages/nagi-laravel-newrelic-log-api)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

142347.8k](/packages/keepsuit-laravel-opentelemetry)[spatie/laravel-error-share

Share your Laravel errors to Flare

43965.6k3](/packages/spatie-laravel-error-share)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98239.8k1](/packages/muhammadhuzaifa-telescope-guzzle-watcher)

PHPackages © 2026

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