marothyzsolt/laravel-new-relic

Laravel Log Handler for New Relic
3,964
Install
composer require marothyzsolt/laravel-new-relic
Latest Version:2.0.2
PHP:^8.0|^8.1
License:MIT
Last Updated:Sep 24, 2022
Links: GitHub  ·  Packagist
Maintainer: marothyzsolt

Laravel New Relic Logger

Latest Version on Packagist Total Downloads

Installation

You can install the package via composer:

composer require marothyzsolt/laravel-new-relic

Usage

Change config/logging.php file with the following code:

'single' => [
    'driver' => env('APP_ENV') === 'local' ? 'single' : 'custom',
    'via' => NewRelicLogger::class,
    'path' => storage_path('logs/laravel.log'),
    'level' => env('LOG_LEVEL', 'debug'),
],

You have to specify these the environment variables:

NEW_RELIC_APP_NAME="app-name"
NEW_RELIC_LICENSE_KEY="newrelic-license-key-here"

Custom Extra Data

You can add more data to send to New Relic. Firstly publish the config file.

php artisan vendor:publish --provider="MarothyZsolt\LaravelNewRelic\LaravelNewRelicServiceProvider"

Now you see the config file structure, and you can extend the Closure.

'extra_data' => function (?Request $request, ?Throwable $throwable): array {
    return [
        'fingerprint' => $request->fingerprint(),
    ];
}

Detailed Exception Logging (Optional)

If you want to log exceptions with stacktrace as well, you can use the following. Extends the app/Exceptions/Handler.php

public function register()
{
    $this->reportable(function (Throwable $e) {
        app(\App\Logging\NewRelicLogger::class)->throwable($e);
    });
}

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

jackwh/laravel-new-relic

Monitor your Laravel application performance with New Relic

1,139,605 113
iskander-g/laravel-new-relic

Monitor your Laravel application performance with New Relic

2,389 0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959

Version History

Version Released PHP Laravel License
2.0.2 ^8.0|^8.1 ^8.0|^9.0 MIT
2.0.1 ^8.0|^8.1 ^8.0|^9.0 MIT
2.0.0 ^8.0|^8.1 ^8.0|^9.0 MIT
1.0.3 ^8.0|^8.1 ^8.0 MIT
1.0.2 ^8.0|^8.1 ^8.0 MIT