PHP code example of nagi / laravel-newrelic-log-api

1. Go to this page and download the library: Download nagi/laravel-newrelic-log-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nagi / laravel-newrelic-log-api example snippets


    // 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!');

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,
];


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


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

    protected $listen = [
        NewrelicLogApiResponseEvent::class => [
            NewrelicLogApiResponseListener::class,
        ],
    ];
bash
php artisan vendor:publish --tag="laravel-newrelic-log-api-config"