patrickmaken/kafka-log-driver
Laravel, log driver for Kafka
1,169
| Install | |
|---|---|
composer require patrickmaken/kafka-log-driver |
|
| Latest Version: | 4.0 |
| PHP: | ^8.1 |
| License: | MIT |
| Last Updated: | May 29, 2025 |
| Links: | GitHub · Packagist |
Maintainer: patrickbalemaken
Laravel log driver for Kafka
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 patrickmaken/kafka-log-driver
For Laravel 9
composer require patrickmaken/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' => Patrickmaken\KafkaLogDriver\KafkaLogger::class,
],
...
],
License
The MIT License (MIT). Please see License File for more information.