From 685d072a35078110b4e6452fc934bb97e01fd0e3 Mon Sep 17 00:00:00 2001 From: NopeCharon <115794254+NopeCharon@users.noreply.github.com> Date: Sat, 28 Nov 2026 05:10:33 +0000 Subject: [PATCH] java: note that fluent-logger-java is not maintained and add Fluency fluent-logger-java has not been updated since 2019, and the Fluentd maintainers answered in fluent/fluent-logger-java#99 that its maintenance has stalled and that Fluency may be recommended instead. The Java article still presented it as the way to send records from Java without any note. Add a warning about this at the top of the article, and a section that shows how to send records with Fluency: the Maven dependencies, a sample application, and that Fluency#close must be called to flush the buffered records. Keep the fluent-logger-java section for existing users. Update the description of the page in llms.txt accordingly. Fixes #482 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com> --- language-bindings/java.md | 62 +++++++++++++++++++++++++++++++++++++-- llms.txt | 2 +- 2 files changed, 61 insertions(+), 3 deletions(-) diff --git a/language-bindings/java.md b/language-bindings/java.md index 8b2196f2..7c0dd735 100644 --- a/language-bindings/java.md +++ b/language-bindings/java.md @@ -2,13 +2,17 @@ The [`fluent-logger-java`](https://github.com/fluent/fluent-logger-java) library is used to post records from Java applications to Fluentd. -This article explains how to use it. +{% hint style='warning' %} +`fluent-logger-java` is not actively maintained. It has not been updated since 2019, and the Fluentd maintainers are looking for someone to maintain it \(see [fluent/fluent-logger-java#99](https://github.com/fluent/fluent-logger-java/issues/99)\). For new applications, consider [Fluency](https://github.com/komamitsu/fluency) instead. +{% endhint %} + +This article explains how to use Fluency and `fluent-logger-java`. ## Prerequisites * Basic knowledge of Java * Basic knowledge of Fluentd -* Java 7 or higher +* Java 8 or higher \(Fluency\) or Java 7 or higher \(`fluent-logger-java`\) ## Installing Fluentd @@ -37,6 +41,60 @@ Restart Fluentd after configuring. $ sudo systemctl restart fluentd ``` +## Using Fluency + +[Fluency](https://github.com/komamitsu/fluency) is a logger which sends records to Fluentd with the [forward protocol](../input/forward.md). It buffers the records in memory and sends them asynchronously. It also supports failover between multiple Fluentd instances, ack responses, and TLS. + +Add the following dependency configuration to `pom.xml`. The latest version can be found in [CHANGELOG.md](https://github.com/komamitsu/fluency/blob/master/CHANGELOG.md): + +```text + + ... + + org.komamitsu + fluency-core + ${fluency.version} + + + org.komamitsu + fluency-fluentd + ${fluency.version} + + ... + +``` + +Here's a sample Java test application: + +```text +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import org.komamitsu.fluency.Fluency; +import org.komamitsu.fluency.fluentd.FluencyBuilderForFluentd; + +public class Main { + public static void main(String[] args) throws IOException { + // Sends records to localhost:24224 + Fluency fluency = new FluencyBuilderForFluentd().build(); + + Map data = new HashMap(); + data.put("from", "userA"); + data.put("to", "userB"); + fluency.emit("fluentd.test.follow", data); + + // Flushes the buffered records and releases the resources + fluency.close(); + } +} +``` + +Executing the above program will send the record with the `fluentd.test.follow` tag to Fluentd, and it will be output via the [`stdout`](../output/stdout.md) output plugin. + +`Fluency#emit` does not send the record at once. Call `Fluency#close` before the application exits, or the buffered records may be lost. If the buffer is full, `Fluency#emit` throws `org.komamitsu.fluency.BufferFullException`. + +More information on Fluency, such as the buffer and retry settings, can be found [here](https://github.com/komamitsu/fluency). + ## Using `fluent-logger-java` Add the following dependency configuration to `pom.xml`. The logger's revision information can be found in [CHANGES.txt](https://github.com/fluent/fluent-logger-java/blob/master/CHANGES.txt): diff --git a/llms.txt b/llms.txt index c9f19dfd..7b86be4e 100644 --- a/llms.txt +++ b/llms.txt @@ -231,7 +231,7 @@ Documentation for the end-of-life v0.12 series is at https://docs.fluentd.org/0. ## Language Bindings - [Language Bindings](https://docs.fluentd.org/language-bindings/README.md): Index of the client libraries that send events to Fluentd. -- [Java](https://docs.fluentd.org/language-bindings/java.md): The `fluent-logger-java` library is used to post records from Java applications to Fluentd. +- [Java](https://docs.fluentd.org/language-bindings/java.md): How to post records from Java applications to Fluentd with Fluency or the `fluent-logger-java` library, which is not actively maintained. - [Ruby](https://docs.fluentd.org/language-bindings/ruby.md): The `fluent-logger-ruby` library is used to post records from Ruby applications to Fluentd. - [Python](https://docs.fluentd.org/language-bindings/python.md): The `fluent-logger-python` library is used to post records from Python applications to Fluentd. - [Perl](https://docs.fluentd.org/language-bindings/perl.md): The `Fluent::Logger` library is used to post records from Perl applications to Fluentd.