Tatiana Goretskaya
Tatiana Goretskaya

Reputation: 586

log4j2 to elastic search configuration

I am trying to configure log4j2 to elasticsearch and got the next problem:

ERROR No Elasticsearch client factory [JestHttp|ElasticsearchBulkProcessor] provided for AsyncBatchDelivery: clientObjectFactory

But I have property JestHttp set up, so, it should work as clientObjectFactory to my understanding.

Any ideas?

my config file looks like that:

<Configuration status="INFO">
    <Appenders>
        <Elasticsearch name="elasticsearchAsyncBatch">
            <RollingIndexName indexName="log4j2" pattern="yyyy-MM-dd" />
            <AsyncBatchDelivery>
                <JestHttp serverUris="myhost:9200" />
            </AsyncBatchDelivery>
        </Elasticsearch>
    </Appenders>
    <Loggers>
        <Logger name="MyLogger" level="info" additivity="true">
            <AppenderRef ref="elasticsearchAsyncBatch" />
        </Logger>
    </Loggers>
</Configuration>

Upvotes: 1

Views: 3860

Answers (2)

rfoltyns
rfoltyns

Reputation: 389

I'm the owner of this plugin. You need only one of the following:

  • log4j2-elasticsearch-jest
  • log4j2-elasticsearch-hc
  • log4j2-elasticsearch(x)-bulkprocessor

log4j2-elasticsearch-core is a compile dependency of each one of them, so it will get there anyway. It has to be specified only if you write your own extensions of core classses.

Upvotes: 4

Tatiana Goretskaya
Tatiana Goretskaya

Reputation: 586

Looks like I needed not only log4j2-elasticsearch-core dependency, but log4j2-elasticsearch-jest as well.

So, just added the next code to pom:

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

Maybe this will help someone else.

Upvotes: 1

Related Questions