Giter Site home page Giter Site logo

fluent-logger-java's Introduction

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

fluent-logger-java's People

Contributors

muga avatar komamitsu avatar xerial avatar colinhebert avatar oza avatar wsalembi avatar frsyuki avatar pxcurtis avatar flozano avatar henryyao369 avatar cosmo0920 avatar kzk avatar tatsuyafw avatar yyuu avatar amdelamar avatar todesking avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.