You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2013/08/24 20:45:52 UTC
git commit: SQOOP-744: Sqoop2: Supply log4j configuration for
generated mapreduce job
Updated Branches:
refs/heads/sqoop2 da06408f2 -> 48530e3f8
SQOOP-744: Sqoop2: Supply log4j configuration for generated mapreduce job
(Raghav Kumar Gautam via Jarek Jarcec Cecho)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/48530e3f
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/48530e3f
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/48530e3f
Branch: refs/heads/sqoop2
Commit: 48530e3f8b9cb2770461d9b4e8e291ae15d47156
Parents: da06408
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Sat Aug 24 11:45:14 2013 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Sat Aug 24 11:45:14 2013 -0700
----------------------------------------------------------------------
.../apache/sqoop/job/mr/ConfigurationUtils.java | 17 +++++++++++++++
.../org/apache/sqoop/job/mr/SqoopMapper.java | 3 +++
.../org/apache/sqoop/job/mr/SqoopReducer.java | 3 +++
.../main/resources/META-INF/log4j.properties | 23 ++++++++++++++++++++
4 files changed, 46 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/48530e3f/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
index f5f6d8e..bd11323 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/ConfigurationUtils.java
@@ -21,6 +21,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapreduce.Job;
+import org.apache.log4j.PropertyConfigurator;
import org.apache.sqoop.job.JobConstants;
import org.apache.sqoop.json.util.SchemaSerialization;
import org.apache.sqoop.model.FormUtils;
@@ -30,6 +31,9 @@ import org.apache.sqoop.utils.ClassUtils;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
+import java.io.InputStream;
+import java.util.Properties;
+
/**
* Helper class to store and load various information in/from MapReduce configuration
* object and JobConf object.
@@ -261,4 +265,17 @@ public final class ConfigurationUtils {
private ConfigurationUtils() {
// Instantiation is prohibited
}
+
+ public static void configureLogging() {
+ try {
+ Properties props = new Properties();
+ InputStream resourceAsStream =
+ SqoopMapper.class.getResourceAsStream("/META-INF/log4j.properties");
+ props.load(resourceAsStream);
+ PropertyConfigurator.configure(props);
+ } catch (Exception e) {
+ System.err.println("Encountered exception while configuring logging " +
+ "for sqoop: " + e);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/sqoop/blob/48530e3f/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java
index 59cf391..92de37e 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopMapper.java
@@ -43,6 +43,9 @@ import org.apache.sqoop.utils.ClassUtils;
*/
public class SqoopMapper extends Mapper<SqoopSplit, NullWritable, Data, NullWritable> {
+ static {
+ ConfigurationUtils.configureLogging();
+ }
public static final Logger LOG = Logger.getLogger(SqoopMapper.class);
/**
http://git-wip-us.apache.org/repos/asf/sqoop/blob/48530e3f/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java
index b31161c..98a2c51 100644
--- a/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java
+++ b/execution/mapreduce/src/main/java/org/apache/sqoop/job/mr/SqoopReducer.java
@@ -32,6 +32,9 @@ import java.util.concurrent.TimeUnit;
*/
public class SqoopReducer extends Reducer<Data, NullWritable, Data, NullWritable> {
+ static {
+ ConfigurationUtils.configureLogging();
+ }
public static final Logger LOG = Logger.getLogger(SqoopReducer.class);
/**
http://git-wip-us.apache.org/repos/asf/sqoop/blob/48530e3f/execution/mapreduce/src/main/resources/META-INF/log4j.properties
----------------------------------------------------------------------
diff --git a/execution/mapreduce/src/main/resources/META-INF/log4j.properties b/execution/mapreduce/src/main/resources/META-INF/log4j.properties
new file mode 100644
index 0000000..0f34f97
--- /dev/null
+++ b/execution/mapreduce/src/main/resources/META-INF/log4j.properties
@@ -0,0 +1,23 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Set root logger level to DEBUG and its only appender to A1.
+log4j.logger.org.apache.sqoop=ALL, A1
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.Target = System.err
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c %x - %m%n