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.4.x) is available here.

Project consists of:

Features

Roadmap

Usage

  1. Add this snippet to your pom.xml file:
    <dependency>
    <groupId>org.appenders.log4j</groupId>
    <artifactId>log4j2-elasticsearch-jest</artifactId>
    <version>1.4.3</version>
    </dependency>

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

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

or use new, optimized Apache HC based HTTP client

or log4j2.properties

or configure programmatically

  1. 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.

Dependencies

Be aware that Jackson FasterXML jars that has to be provided by user for this library to work in default mode. Please visit mvnrepository for an overview of provided and compile dependencies

Released to Sonatype OSS repos

Visit submodules' documentation or mvnrepository for XML snippets.