PHP code example of muhammadnurmatov / amqp-gelf-logger

1. Go to this page and download the library: Download muhammadnurmatov/amqp-gelf-logger 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/ */

    

muhammadnurmatov / amqp-gelf-logger example snippets


return [
    'rabbitmq' => [
        'host' => env('RABBITMQ_HOST'),
        'port' => env('RABBITMQ_PORT', 5672),
        'user' => env('RABBITMQ_USER'),
        'password' => env('RABBITMQ_PASSWORD'),
        'vhost' => env('RABBITMQ_VHOST', '/'),
        'exchange' => env('RABBITMQ_EXCHANGE'),
        'exchange_type' => env('RABBITMQ_EXCHANGE', 'topic'),
        'routing_key' => env('LOG_RABBITMQ_EXCHANGE'),
        'use_tls' => env('RABBITMQ_USE_TLS', false),
        'verify_peer' => env('RABBITMQ_VERIFY_PEER', false),
        'verify_peer_name' => env('RABBITMQ_VERIFY_PEER_NAME', false),
        'cafile' => env('RABBITMQ_CAFILE'),
        'local_cert' => env('RABBITMQ_LOCAL_CERT'),
        'local_pk' => env('RABBITMQ_LOCAL_PK'),
        'app_name' => env('APP_NAME', 'Laravel'),
        'app_env' => env('APP_ENV', 'production'),
        'level' => env('RABBITMQ_LOG_LEVEL', 'debug'),
        'path' => storage_path('logs/logger/logs.log'),
        'days' => 14,
    ]
];

'amqp' => [
    'driver' => 'custom',
    'via' => \MuhammadN\AmqpGelfLogger\RabbitMQLogger::class,
    'name' => 'graylog',
    'level' => 'debug',
    'path' => storage_path('logs/graylog.log'),
    'days' => 14,
],

use Illuminate\Support\Facades\Log;

Log::channel('amqp')->info('User logged in', ['user_id' => 1]);
Log::channel('amqp')->error('Something broke!', ['exception' => $exception]);