alexusmai / kafka-log-driver
Laravel, log driver for Kafka
Installs: 1 356
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 1
Requires
- php: ^8.1|^8.2
- ext-rdkafka: ^6.0
- illuminate/contracts: ^10.0
- illuminate/support: ^10.0
- monolog/monolog: ^3.0
This package is auto-updated.
Last update: 2024-10-27 12:59:41 UTC
README
Requirements:
- PHP 8.1, 8.2
- Laravel 9, 10
- rdkafka php extension v.6
sudo pecl install rdkafka
Add the following line to your php.ini file:
extension=rdkafka.so
Installation
You can install the package via composer:
composer require alexusmai/kafka-log-driver
For Laravel 9
composer require alexusmai/kafka-log-driver:1.0
You can publish the config file with:
php artisan vendor:publish --tag="kafka-log-driver-config"
This is the contents of the published config file (kafka_log.php):
return [ // topic name 'topic' => env('KAFKA_LOG_FILE_TOPIC'), // kafka brokers - "10.0.0.1,10.0.0.2" 'brokers' => env('KAFKA_LOG_BROKERS'), // timeout - ms 'flush_timeout' => env('KAFKA_LOG_FLUSH_TIMEOUT', 100) ];
Usage
Add to .env
KAFKA_LOG_FILE_TOPIC=
KAFKA_LOG_BROKERS=
// if you want to change the default value (100 ms)
KAFKA_LOG_FLUSH_TIMEOUT=
Add to config/logging.php
'channels' => [ ... 'kafka' => [ 'driver' => 'custom', 'via' => Alexusmai\KafkaLogDriver\KafkaLogger::class, ], ... ],
License
The MIT License (MIT). Please see License File for more information.