Giter VIP home page Giter VIP logo

log4j2-elasticsearch's Introduction

log4j2-elasticsearch overview

Build Status Maven Central codecov contributions welcome

This is a parent project for log4j2 appender plugins capable of pushing logs in batches to Elasticsearch clusters.

Latest released code (1.6.x) is available here.

Project consists of:

  • log4j2-elasticsearch-core - skeleton provider for conrete implementations
  • log4j2-elasticsearch-hc - optimized Apache Async HTTP client compatible with Elasticsearch 2.x, 5.x, 6.x, 7.x and 8.x clusters
  • (Since 1.6.0) log4j2-elasticsearch-ahc - AsyncHttpClient compatible with Elasticsearch 2.x, 5.x, 6.x, 7.x and 8.x clusters
  • log4j2-elasticsearch-jest - Jest HTTP Client compatible with Elasticsearch 2.x, 5.x, 6.x, 7.x and 8.x clusters
  • log4j2-elasticsearch2-bulkprocessor - TCP client compatible with 2.x clusters
  • log4j2-elasticsearch5-bulkprocessor - TCP client compatible with 5.x and 6.x clusters
  • log4j2-elasticsearch6-bulkprocessor - TCP client compatible with 6.x clusters

Features

Roadmap contributions welcome

  • Send Metrics to Elasticsearch
  • Prep for "batch-core" (or whatever the final name is) module based on common AHC and HC classes
  • More Elasticsearch API integrations
  • TRY to maintain compatibility with OpenSearch

Feature Requests welcome!

Usage

  1. Add this snippet to your pom.xml file:

    <dependency>
        <groupId>org.appenders.log4j</groupId>
        <artifactId>log4j2-elasticsearch-jest</artifactId>
        <version>1.6.1</version>
    </dependency>

    Ensure that Log4j2 and Jackson FasterXML jars are added as well - see Dependencies section below

  2. Use simple log4j2.xml configuration:

    <Appenders>
        <Elasticsearch name="elasticsearchAsyncBatch">
            <IndexName indexName="log4j2" />
            <JacksonJsonLayout />
            <AsyncBatchDelivery>
                <IndexTemplate name="log4j2" path="classpath:indexTemplate.json" />
                <JestHttp serverUris="http://localhost:9200" />
            </AsyncBatchDelivery>
        </Elasticsearch>
    </Appenders>

    or use optimized Apache HC based HTTP client

    or new AsyncHttpClient (Netty) based HTTP client

    or log4j2.properties

    or configure programmatically

    NOTE: indexTemplate.json file is not a part of main jars. You have to create it on your own (because only YOU know which mapping you'd like to use). You can find a few basic ones in tests jars and log4j2-elasticsearch-examples.

  3. Start logging directly to Elasticsearch!

    Logger log = LogManager.getLogger("Logger that references elasticsearchAsyncBatch")
    log.info("Hello, World!");

    Logs not arriving? Visit examples and verify your config.

General recommendations

  • Start simple with jest module. Suitable for smaller loads, up to few thousands of logs per second
  • Use hc up to 100-200kps (depends on log size and network bandwidth)
  • Use ahc and GZIP for all of the above and 200kps+ (depends on log size and network bandwidth)

Dependencies

Be aware that Jackson FasterXML, Log4j2, Apache HC, AsyncHttpClient, Netty, Chronicle or JCTools jars (depends on the module you choose) may need to be provided for this library to work. By design, you can choose which jars you'd like to have on your classpath. Please visit mvnrepository for an overview of provided and compile dependencies

In order to fix #56, two new modules were extracted from log4j2-elasticsearch-core:

This will not cause any issues if you're using packaging tools with transitive dependencies support (Maven, Gradle, etc.). However, in some cases e.g. if you're managing your jars explicitly, classloaders will complain. Sorry for the inconvenience.

Released to Sonatype OSS repos

Visit submodules' documentation or mvnrepository for XML snippets.

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.