Skip to content

Commit

Permalink
Merge pull request apache#1144 from metamx/javaLoggingManager
Browse files Browse the repository at this point in the history
Add log4j2 hooks to other loggings
  • Loading branch information
xvrl committed Mar 12, 2015
2 parents 3892a94 + edfcea1 commit 7fb4b1d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
8 changes: 8 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<!-- com.lmax.disruptor is optional in log4j-core, so we explicitly include it here -->
<dependency>
<groupId>com.lmax</groupId>
Expand Down
3 changes: 2 additions & 1 deletion docs/content/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ This describes the common configuration shared by all Druid nodes. These configu

## JVM Configuration Best Practices

There are three JVM parameters that we set on all of our processes:
There are four JVM parameters that we set on all of our processes:

1. `-Duser.timezone=UTC` This sets the default timezone of the JVM to UTC. We always set this and do not test with other default timezones, so local timezones might work, but they also might uncover weird and interesting bugs.
2. `-Dfile.encoding=UTF-8` This is similar to timezone, we test assuming UTF-8. Local encodings might work, but they also might result in weird and interesting bugs.
3. `-Djava.io.tmpdir=<a path>` Various parts of the system that interact with the file system do it via temporary files, and these files can get somewhat large. Many production systems are set up to have small (but fast) `/tmp` directories, which can be problematic with Druid so we recommend pointing the JVM’s tmp directory to something with a little more meat.
4. `-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager` This allows log4j2 to handle logs for non-log4j2 components (like jetty) which use standard java logging.

### Extensions

Expand Down
2 changes: 2 additions & 0 deletions docs/content/Logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ java -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 \

Note the "-classpath" in this example has the config dir before the jars under lib/*.

To enable java logging to go through log4j2, set the `-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager` server parameter.

An example log4j2.xml ships with Druid under config/_common/log4j2.xml, and a sample file is also shown below:

```
Expand Down
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<druid.api.version>0.3.5</druid.api.version>
<jackson.version>2.4.4</jackson.version>
<log4j.version>2.1</log4j.version>
<slf4j.version>1.7.10</slf4j.version>
</properties>

<modules>
Expand Down Expand Up @@ -400,6 +401,25 @@
<artifactId>log4j-1.2-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<!-- This is not slf4j's version because of performance concerns
http://www.slf4j.org/api/org/slf4j/bridge/SLF4JBridgeHandler.html
Please make sure to do performance tests before switching this to slf4j
Users wishing to use slf4j's solution are encouraged to also use
Logback
More info at
http://logback.qos.ch/manual/configuration.html#LevelChangePropagator
http://www.slf4j.org/legacy.html#jul-to-slf4j
-->
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
Expand Down

0 comments on commit 7fb4b1d

Please sign in to comment.