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!');
Does your business depend on my contributions? Reach out and support me on PayPal. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.
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', env('QUEUE_CONNECTION')),
/**
* 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.
https://one.newrelic.com/api-keys
NEWRELIC_ENABLED=true
NEWRELIC_API_KEY=<your_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
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')
],
in logging.php
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'newrelic-log-api'],
'ignore_exceptions' => false,
],
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,
],
];
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
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.
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.