Skip to content
Log4j2 Elasticsearch Appender plugins
Branch: master
Clone or download

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.

Project consists of:

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


  • Asynchronous log delivery
  • Batch size and flush interval configuration
  • Failover (redirect failed batch to alternative target)
  • JSON message format (user-provided or JacksonJsonLayout by default since 1.3 or Log4j2 JsonLayout)
  • (since 1.1) Index rollover (hourly, daily, etc.)
  • (1.1) Index template configuration
  • (1.2) Basic Authentication (XPack Security and Shield support)
  • (1.2) HTTPS support (XPack Security and Shield - visit submodules for compatibility matrix)
  • (1.3) Buffer object pool (memory allocation reduced by ~80%)
  • (1.3) Buffered Jest HTTP client
  • (1.3) Fully configurable JSON output using JacksonJsonLayout
  • (1.4 - H2 2019) Reliable, file-based failover/retry
  • (1.4) log4j2-elasticsearch-hc module - optimized async HTTP client


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

(ensure that Log4j2 and Jackson FasterXML jars are added as well - see Dependencies section below)

  1. Add this snippet to log4j2.xml configuration:
    <Elasticsearch name="elasticsearchAsyncBatch">
        <IndexName indexName="log4j2" />
            <IndexTemplate name="log4j2" path="classpath:indexTemplate.json" />
            <JestHttp serverUris="http://localhost:9200" />

or (see example)

or configure programmatically

  1. Start logging directly to Elasticsearch!
Logger log = LogManager.getLogger("Logger that references elasticsearchAsyncBatch")"Hello, World!");


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.

You can’t perform that action at this time.