# kafka: Publish messages to Apache Kafka (Java implementation)

Starting with version 3.7, AxoSyslog can directly publish log messages to the [Apache Kafka](<http://kafka.apache.org>) message bus, where subscribers can access them.

  * Since AxoSyslog uses the official Java Kafka producer, the `kafka` destination has significant memory usage.



## Declaration:
```
       @include "scl.conf"
        
        kafka(
            client-lib-dir("/opt/syslog-ng/lib/syslog-ng/java-modules/:<path-to-preinstalled-kafka-libraries>")
            kafka-bootstrap-servers("1.2.3.4:9092,192.168.0.2:9092")
            topic("${HOST}")
        
        );
    
```

## Example: Sending log data to Apache Kafka

The following example defines a `kafka` destination, using only the required parameters.
```
 
       @include "scl.conf"
        
        destination d_kafka {
          kafka(
            client-lib-dir("/opt/syslog-ng/lib/syslog-ng/java-modules/KafkaDestination.jar:/usr/share/kafka/lib/")
            kafka-bootstrap-servers("1.2.3.4:9092,192.168.0.2:9092")
            topic("${HOST}")
          );
        };
    
```

  * To install the software required for the `kafka` destination, see [Prerequisites](../../docs/axosyslog-core/chapter-destinations/configuring-destinations-kafka/destination-kafka-prerequisites/index.md).

  * For details on how the `kafka` destination works, see [How AxoSyslog interacts with Apache Kafka](../../docs/axosyslog-core/chapter-destinations/configuring-destinations-kafka/destination-kafka-interaction/index.md).

  * For the list of options, see [Kafka destination options](../../docs/axosyslog-core/chapter-destinations/configuring-destinations-kafka/reference-destination-kafka/index.md).




The `kafka()` driver is actually a reusable configuration snippet configured to receive log messages using the Java language-binding of AxoSyslog. For details on using or writing such configuration snippets, see [Reusing configuration blocks](../../docs/axosyslog-core/chapter-configuration-file/large-configs/config-blocks/index.md). You can find the source of the kafka configuration snippet on [GitHub](<https://github.com/axoflow/axosyslog/blob/main/scl/kafka/kafka.conf>).

Note If you delete all Java destinations from your configuration and reload `syslog-ng`, the JVM is not used anymore, but it is still running. If you want to stop JVM, stop `syslog-ng` and then start `syslog-ng` again. 

* * *

[Prerequisites](../../docs/axosyslog-core/chapter-destinations/configuring-destinations-kafka/destination-kafka-prerequisites/index.md)

[How AxoSyslog interacts with Apache Kafka](../../docs/axosyslog-core/chapter-destinations/configuring-destinations-kafka/destination-kafka-interaction/index.md)

[Kafka destination options](../../docs/axosyslog-core/chapter-destinations/configuring-destinations-kafka/reference-destination-kafka/index.md)

Last modified November 20, 2024: [Broken link updates (5644de9)](<https://github.com/axoflow/axosyslog-core-docs/commit/5644de9a8069da37e3bebf0ed5a4e73cf958a66b>)