mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-24 17:09:48 +00:00
Add documentation for Logger with Transport Client
Backport of #21477 in master branch
This commit is contained in:
parent
9352d16602
commit
5336e72fbb
@ -6,6 +6,7 @@ spatial4j = 0.6
|
||||
jts = 1.13
|
||||
jackson = 2.8.1
|
||||
snakeyaml = 1.15
|
||||
# When updating log4j, please update also docs/java-api/index.asciidoc
|
||||
log4j = 2.7
|
||||
slf4j = 1.6.2
|
||||
jna = 4.2.2
|
||||
|
@ -35,6 +35,70 @@ For example, you can define the latest version in your `pom.xml` file:
|
||||
</dependency>
|
||||
--------------------------------------------------
|
||||
|
||||
=== Log4j 2 Logger
|
||||
|
||||
You need to also include Log4j 2 dependencies:
|
||||
|
||||
["source","xml",subs="attributes"]
|
||||
--------------------------------------------------
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
--------------------------------------------------
|
||||
|
||||
And also provide a Log4j 2 configuration file in your classpath.
|
||||
For example, you can add in your `src/main/resources` project dir a `log4j2.properties` file like:
|
||||
|
||||
|
||||
["source","properties",subs="attributes"]
|
||||
--------------------------------------------------
|
||||
appender.console.type = Console
|
||||
appender.console.name = console
|
||||
appender.console.layout.type = PatternLayout
|
||||
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%m%n
|
||||
|
||||
rootLogger.level = info
|
||||
rootLogger.appenderRef.console.ref = console
|
||||
--------------------------------------------------
|
||||
|
||||
=== Using another Logger
|
||||
|
||||
If you want to use another logger than Log4j 2, you can use http://www.slf4j.org/[SLF4J] bridge to do that:
|
||||
|
||||
["source","xml",subs="attributes"]
|
||||
--------------------------------------------------
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-to-slf4j</artifactId>
|
||||
<version>2.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
--------------------------------------------------
|
||||
|
||||
http://www.slf4j.org/manual.html[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:
|
||||
|
||||
["source","xml",subs="attributes"]
|
||||
--------------------------------------------------
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
--------------------------------------------------
|
||||
|
||||
|
||||
== Dealing with JAR dependency conflicts
|
||||
|
||||
If you want to use Elasticsearch in your Java application, you may have to deal with version conflicts with third party
|
||||
|
Loading…
x
Reference in New Issue
Block a user