elasticsearch java api 配置文件

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

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.8.2</version></dependency><dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.8.2</version></dependency>

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:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-to-slf4j</artifactId>
    <version>2.8.2</version></dependency><dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.24</version>
  </dependency>

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:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.21</version></dependency>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章