Search code examples
elasticsearchlog4jlog4j2elastic-stack

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>

Solution

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