Package Data | |
---|---|
Maintainer Username: | tasmidur |
Maintainer Contact: | tasmidurrahman@example.com (Md Tasmidur Rahman) |
Package Create Date: | 2022-08-21 |
Package Last Update: | 2023-01-25 |
Home Page: | https://packagist.org/packages/tasmidur/kafka-monolog-handler |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-17 03:09:30 |
Package Statistics | |
---|---|
Total Downloads: | 2,078 |
Monthly Downloads: | 54 |
Daily Downloads: | 0 |
Total Stars: | 4 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 1 |
Kafka Monolog Handler is used for storing laravel log into the Kafka message broker that's why any consumer like ELK or any other log manager can consume in an asynchronous way
| Dependency | Requirement |
|--------------------------------------------------------|-------------|
| php | >=8.0
|
| Laravel | >=8.0
|
This package also requires the rdkafka php extension, which you can install by following this documentation
Install kafka-monolog-handler
.
composer require tasmidur/kafka-monolog-handler
1.Modify config/logging.php
.
return [
'channels' => [
// ...
'kafka' => \Tasmidur\KafkaLogger\KafkaLogger::getInstance(
topicName: env('KAFKA_LOG_FILE_TOPIC', 'system_logs'),
brokers: env('KAFKA_BROKERS')
),
],
];
return [
'channels' => [
// ...
'kafka' => \Tasmidur\KafkaLogger\KafkaLogger::getInstance(
topicName: env('KAFKA_LOG_FILE_TOPIC', 'system_logs'),
brokers: env('KAFKA_BROKERS'),
options: [
'sasl_config' => [
'username' => env('KAFKA_BROKER_USERNAME'),
'password' => env('KAFKA_BROKER_PASSWORD'),
'mechanisms' => env('KAFKA_BROKER_MECHANISMS'),
'security_protocol' => env('KAFKA_BROKER_SECURITY_PROTOCOL')
]
]
),
],
];
2.Modify .env
.
LOG_CHANNEL=kafka
KAFKA_BROKERS=kafka:9092,kafka:9093
KAFKA_LOG_FILE_TOPIC=laravel-logs
KAFKA_BROKER_USERNAME=username
KAFKA_BROKER_PASSWORD=password
KAFKA_BROKER_MECHANISMS=SCRAM-SHA-512 or other
KAFKA_BROKER_SECURITY_PROTOCOL=SASL_SSL or other