elasticsearch java api 网址:https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-search.html

在使用Maven创建Elasticsearch是其pom.xml的文件中必须要加入Log4j 2的依赖

elasticsearch 5.4


    org.apache.logging.log4j
    log4j-api
    2.8.2
    org.apache.logging.log4j
    log4j-core
    2.8.2

And also provide a Log4j 2 configuration file in your classpath. For example, you can add in yoursrc/main/resources project dir a log4j2.properties file like:

appender.console.type = Consoleappender.console.name = console
appender.console.layout.type = PatternLayoutrootLogger.level = info
rootLogger.appenderRef.console.ref = console





If you want to use another logger than Log4j 2, you can use SLF4J bridge to do that:


    org.apache.logging.log4j
    log4j-to-slf4j
    2.8.2
    org.slf4j
    slf4j-api
    1.7.24
  

This page lists implementations you can use. Pick your favorite logger and add it as a dependency. As an example, we will use the slf4j-simple logger:


    org.slf4j
    slf4j-simple
    1.7.21