Browse Source

Add documentation for Logger with Transport Client

Backport of #21477 in master branch
David Pilato 9 years ago
parent
commit
5336e72fbb
2 changed files with 65 additions and 0 deletions
  1. 1 0
      buildSrc/version.properties
  2. 64 0
      docs/java-api/index.asciidoc

+ 1 - 0
buildSrc/version.properties

@@ -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

+ 64 - 0
docs/java-api/index.asciidoc

@@ -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