diff options
author | Patrick Wendell <pwendell@gmail.com> | 2014-01-07 12:42:19 -0800 |
---|---|---|
committer | Patrick Wendell <pwendell@gmail.com> | 2014-01-07 12:56:24 -0800 |
commit | e688e11206401850a13a87d7db52941cc716f88a (patch) | |
tree | 890582f5f577909e2fdd0463fb9726e51a014af6 | |
parent | 15d953450167c4ec45c9d0a2c7ab8ee71be2e576 (diff) | |
download | spark-e688e11206401850a13a87d7db52941cc716f88a.tar.gz spark-e688e11206401850a13a87d7db52941cc716f88a.tar.bz2 spark-e688e11206401850a13a87d7db52941cc716f88a.zip |
Add log4j exclusion rule to maven.
To make this work I had to rename the defaults file. Otherwise
maven's pattern matching rules included it when trying to match
other log4j.properties files.
I also fixed a bug in the existing maven build where two
<transformers> tags were present in assembly/pom.xml
such that one overwrote the other.
-rw-r--r-- | assembly/pom.xml | 6 | ||||
-rw-r--r-- | core/src/main/resources/org/apache/spark/log4j-defaults.properties (renamed from core/src/main/resources/org/apache/spark/default-log4j.properties) | 0 | ||||
-rw-r--r-- | core/src/main/scala/org/apache/spark/Logging.scala | 10 | ||||
-rw-r--r-- | examples/pom.xml | 3 |
4 files changed, 12 insertions, 7 deletions
diff --git a/assembly/pom.xml b/assembly/pom.xml index 9b70812c64..54a25910ce 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -108,12 +108,12 @@ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/services/org.apache.hadoop.fs.FileSystem</resource> </transformer> - </transformers> - <transformers> - <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>reference.conf</resource> </transformer> + <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> + <resource>log4j.properties</resource> + </transformer> </transformers> </configuration> </execution> diff --git a/core/src/main/resources/org/apache/spark/default-log4j.properties b/core/src/main/resources/org/apache/spark/log4j-defaults.properties index d72dbadc39..d72dbadc39 100644 --- a/core/src/main/resources/org/apache/spark/default-log4j.properties +++ b/core/src/main/resources/org/apache/spark/log4j-defaults.properties diff --git a/core/src/main/scala/org/apache/spark/Logging.scala b/core/src/main/scala/org/apache/spark/Logging.scala index d519fc5a29..4a34989e50 100644 --- a/core/src/main/scala/org/apache/spark/Logging.scala +++ b/core/src/main/scala/org/apache/spark/Logging.scala @@ -104,13 +104,15 @@ trait Logging { // If Log4j doesn't seem initialized, load a default properties file val log4jInitialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements if (!log4jInitialized) { - val defaultLogProps = "org/apache/spark/default-log4j.properties" + val defaultLogProps = "org/apache/spark/log4j-defaults.properties" val classLoader = this.getClass.getClassLoader Option(classLoader.getResource(defaultLogProps)) match { - case Some(url) => PropertyConfigurator.configure(url) - case None => System.err.println(s"Spark was unable to load $defaultLogProps") + case Some(url) => + PropertyConfigurator.configure(url) + log.info(s"Using Spark's default log4j profile: $defaultLogProps") + case None => + System.err.println(s"Spark was unable to load $defaultLogProps") } - log.info(s"Using Spark's default log4j profile: $defaultLogProps") } Logging.initialized = true diff --git a/examples/pom.xml b/examples/pom.xml index 7a7032c319..7e41bef252 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -203,6 +203,9 @@ <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>reference.conf</resource> </transformer> + <transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer"> + <resource>log4j.properties</resource> + </transformer> </transformers> </configuration> </execution> |