Fluent Logger for Java

Java implementation of structured logger for Fluent.

License

License

GroupId

GroupId

org.fluentd
ArtifactId

ArtifactId

fluent-logger
Last Version

Last Version

0.3.4
Release Date

Release Date

Type

Type

jar
Description

Description

Fluent Logger for Java
Java implementation of structured logger for Fluent.
Project URL

Project URL

https://github.com/fluent/fluent-logger-java
Source Code Management

Source Code Management

https://github.com/fluent/fluent-logger-java.git

Download fluent-logger

How to add to project

<!-- https://jarcasting.com/artifacts/org.fluentd/fluent-logger/ -->
<dependency>
    <groupId>org.fluentd</groupId>
    <artifactId>fluent-logger</artifactId>
    <version>0.3.4</version>
</dependency>
// https://jarcasting.com/artifacts/org.fluentd/fluent-logger/
implementation 'org.fluentd:fluent-logger:0.3.4'
// https://jarcasting.com/artifacts/org.fluentd/fluent-logger/
implementation ("org.fluentd:fluent-logger:0.3.4")
'org.fluentd:fluent-logger:jar:0.3.4'
<dependency org="org.fluentd" name="fluent-logger" rev="0.3.4">
  <artifact name="fluent-logger" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.fluentd', module='fluent-logger', version='0.3.4')
)
libraryDependencies += "org.fluentd" % "fluent-logger" % "0.3.4"
[org.fluentd/fluent-logger "0.3.4"]

Dependencies

compile (2)

Group / Artifact Type Version
org.msgpack : msgpack jar 0.6.8
org.slf4j : slf4j-api jar 1.7.6

test (2)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.1
junit : junit jar 4.8.2

Project Modules

There are no modules declared in this project.

Fluent Logger for Java

Build Status

Overview

Many web/mobile applications generate huge amount of event logs (c,f. login, logout, purchase, follow, etc). Analyzing these event logs can be quite valuable for improving services. However, collecting these logs easily and reliably is a challenging task.

Fluentd solves the problem by having: easy installation, small footprint, plugins, reliable buffering, log forwarding, etc.

fluent-logger-java is a Java library, to record events via Fluentd, from Java application.

Requirements

Java >= 1.6

Install

Install with all-in-one jar file

You can download all-in-one jar file for Fluent Logger for Java.

wget http://central.maven.org/maven2/org/fluentd/fluent-logger/${logger.version}/fluent-logger-${logger.version}-jar-with-dependencies.jar   

To use Fluent Logger for Java, set the above jar file to your classpath.

Install from Maven2 repository

Fluent Logger for Java is released on Fluent Maven2 repository. You can configure your pom.xml or build.gradle as follows to use it:

Maven:

<dependencies>
  ...
  <dependency>
    <groupId>org.fluentd</groupId>
    <artifactId>fluent-logger</artifactId>
    <version>${logger.version}</version>
  </dependency>
  ...
</dependencies>

Gradle:

dependencies {
    compile 'org.fluentd:fluent-logger:'+loggerVersion
}

Install from Github repository

You can get latest source code using git.

git clone [email protected]:fluent/fluent-logger-java.git
cd fluent-logger-java
mvn assembly:assembly

You will get the fluent logger jar file in fluent-logger-java/target directory. File name will be fluent-logger-${logger.version}-jar-with-dependencies.jar. For more detail, see pom.xml.

Replace ${logger.version} or loggerVersion with the current version of Fluent Logger for Java.

Quickstart

The following program is a small example of Fluent Logger for Java.

import java.util.HashMap;
import java.util.Map;
import org.fluentd.logger.FluentLogger;

public class Main {
    private static FluentLogger LOG = FluentLogger.getLogger("app");

    public void doApplicationLogic() {
        // ...
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("from", "userA");
        data.put("to", "userB");
        LOG.log("follow", data);
        // ...
    }
}

To create Fluent Logger instances, users need to invoke getLogger method in FluentLogger class like org.slf4j, org.log4j logging libraries. The method should be called only once. By default, the logger assumes fluent daemon is launched locally. You can also specify remote logger by passing the following options.

// for remote fluentd
private static FluentLogger LOG = FluentLogger.getLogger("app", "remotehost", port);

Then, please create the events like this. This will send the event to fluentd, with tag 'app.follow' and the attributes 'from' and 'to'.

Close method in FluentLogger class should be called explicitly when application is finished. The method closes socket connection with the fluentd.

FluentLogger.close();

License

Apache License, Version 2.0

org.fluentd

Fluentd: Unified Logging Layer

Fluentd is a cloud native logging solution to unify data collection and consumption.

Versions

Version
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0