Log4j2 Output Log to es

  elasticsearch, log4j2, springboot

log4j2elastic

<!-- https://mvnrepository.com/artifact/net.inemar.utility/log4j2elastic -->
<dependency>
    <groupId>net.inemar.utility</groupId>
    <artifactId>log4j2elastic</artifactId>
    <version>3.1.0</version>
</dependency>

Log4j2 configuration

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="warn" name="MyApp" packages="">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT" ignoreExceptions="false">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] (%F:%L)  - %m%n" />
        </Console>
        <ElasticAppender name="ElasticAppender" manager="true"/>
    </Appenders>
    <Loggers>
        <Root level="info">
            <AppenderRef ref="Console" />
            <AppenderRef ref="ElasticAppender" level="error" />
        </Root>
    </Loggers>
</Configuration>

Configure environment variables

elastic_local = native://192.168.99.100:9300
elastic_cluster = elasticsearch
service = demo-service

Kibana view

Default logstamp-* view

docs