You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by ya...@apache.org on 2014/07/01 08:10:35 UTC
git commit: SAMZA-215: better logging for interactive command-line
tools
Repository: incubator-samza
Updated Branches:
refs/heads/master 2aad5c4c8 -> 7fd52e870
SAMZA-215: better logging for interactive command-line tools
Project: http://git-wip-us.apache.org/repos/asf/incubator-samza/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-samza/commit/7fd52e87
Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/7fd52e87
Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/7fd52e87
Branch: refs/heads/master
Commit: 7fd52e8700b34e2aa37095edafab3b9aba3b4690
Parents: 2aad5c4
Author: Yan Fang <ya...@gmail.com>
Authored: Mon Jun 30 23:06:36 2014 -0700
Committer: Yan Fang <ya...@gmail.com>
Committed: Mon Jun 30 23:06:36 2014 -0700
----------------------------------------------------------------------
build.gradle | 7 +++-
samza-shell/src/main/bash/checkpoint-tool.sh | 4 +++
samza-shell/src/main/bash/kill-yarn-job.sh | 4 +++
samza-shell/src/main/bash/run-am.sh | 4 +++
samza-shell/src/main/bash/run-class.sh | 4 +--
samza-shell/src/main/bash/run-container.sh | 4 +++
samza-shell/src/main/bash/run-job.sh | 4 +++
.../src/main/resources/log4j-console.xml | 35 ++++++++++++++++++++
8 files changed, 62 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index ebed8f2..72c8b83 100644
--- a/build.gradle
+++ b/build.gradle
@@ -196,13 +196,15 @@ project(":samza-shell") {
gradleShell project(":samza-kafka_$scalaVersion")
gradleShell project(":samza-test_$scalaVersion")
gradleShell project(":samza-yarn_$scalaVersion")
- gradleShell "org.slf4j:slf4j-simple:$slf4jVersion"
+ gradleShell "org.slf4j:slf4j-log4j12:$slf4jVersion"
+ gradleShell "log4j:log4j:1.2.16"
}
task shellTarGz(type: Tar) {
compression = Compression.GZIP
classifier = 'dist'
from 'src/main/bash'
+ from 'src/main/resources'
}
artifacts {
@@ -218,6 +220,7 @@ project(":samza-shell") {
main = 'org.apache.samza.job.JobRunner'
classpath = configurations.gradleShell
if (project.hasProperty('configPath')) args += ['--config-path', configPath]
+ jvmArgs = ["-Dlog4j.configuration=file:src/main/resources/log4j-console.xml"]
}
// Usage: ./gradlew samza-shell:checkpointTool \
@@ -227,6 +230,7 @@ project(":samza-shell") {
classpath = configurations.gradleShell
if (project.hasProperty('configPath')) args += ['--config-path', configPath]
if (project.hasProperty('newOffsets')) args += ['--new-offsets', newOffsets]
+ jvmArgs = ["-Dlog4j.configuration=file:src/main/resources/log4j-console.xml"]
}
// Usage: ./gradlew samza-shell:kvPerformanceTest
@@ -235,6 +239,7 @@ project(":samza-shell") {
main = 'org.apache.samza.test.performance.TestKeyValuePerformance'
classpath = configurations.gradleShell
if (project.hasProperty('configPath')) args += ['--config-path', configPath]
+ jvmArgs = ["-Dlog4j.configuration=file:src/main/resources/log4j-console.xml"]
}
}
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/bash/checkpoint-tool.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/checkpoint-tool.sh b/samza-shell/src/main/bash/checkpoint-tool.sh
index 1a455df..5688b59 100755
--- a/samza-shell/src/main/bash/checkpoint-tool.sh
+++ b/samza-shell/src/main/bash/checkpoint-tool.sh
@@ -16,4 +16,8 @@
# specific language governing permissions and limitations
# under the License.
+if [ -z "$SAMZA_LOG4J_CONFIG" ]; then
+ export SAMZA_LOG4J_CONFIG=file:$(dirname $0)/log4j-console.xml
+fi
+
exec $(dirname $0)/run-class.sh org.apache.samza.checkpoint.CheckpointTool $@
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/bash/kill-yarn-job.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/kill-yarn-job.sh b/samza-shell/src/main/bash/kill-yarn-job.sh
index 924aac6..d42e086 100755
--- a/samza-shell/src/main/bash/kill-yarn-job.sh
+++ b/samza-shell/src/main/bash/kill-yarn-job.sh
@@ -16,4 +16,8 @@
# specific language governing permissions and limitations
# under the License.
+if [ -z "$SAMZA_LOG4J_CONFIG" ]; then
+ export SAMZA_LOG4J_CONFIG=file:$(dirname $0)/log4j-console.xml
+fi
+
exec $(dirname $0)/run-class.sh org.apache.hadoop.yarn.client.cli.ApplicationCLI application -kill $@
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/bash/run-am.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/run-am.sh b/samza-shell/src/main/bash/run-am.sh
index c202596..878d938 100755
--- a/samza-shell/src/main/bash/run-am.sh
+++ b/samza-shell/src/main/bash/run-am.sh
@@ -16,4 +16,8 @@
# specific language governing permissions and limitations
# under the License.
+if [ -z "$SAMZA_LOG4J_CONFIG" ]; then
+ export SAMZA_LOG4J_CONFIG=file:$(dirname $0)/../lib/log4j.xml
+fi
+
exec $(dirname $0)/run-class.sh org.apache.samza.job.yarn.SamzaAppMaster $@
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/bash/run-class.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/run-class.sh b/samza-shell/src/main/bash/run-class.sh
index cc341b7..a75cbb9 100755
--- a/samza-shell/src/main/bash/run-class.sh
+++ b/samza-shell/src/main/bash/run-class.sh
@@ -69,9 +69,7 @@ if [ -z "$JAVA_OPTS" ]; then
if [ $? -eq 0 ] ; then
JAVA_OPTS="$JAVA_OPTS $GC_LOG_ROTATION_OPTS"
fi
- if [ -f $base_dir/lib/log4j.xml ]; then
- JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$base_dir/lib/log4j.xml"
- fi
+ JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=$SAMZA_LOG4J_CONFIG"
fi
echo $JAVA $JAVA_OPTS -cp $CLASSPATH $@
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/bash/run-container.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/run-container.sh b/samza-shell/src/main/bash/run-container.sh
index 72cee18..b43bc3f 100755
--- a/samza-shell/src/main/bash/run-container.sh
+++ b/samza-shell/src/main/bash/run-container.sh
@@ -16,4 +16,8 @@
# specific language governing permissions and limitations
# under the License.
+if [ -z "$SAMZA_LOG4J_CONFIG" ]; then
+ export SAMZA_LOG4J_CONFIG=file:$(dirname $0)/../lib/log4j.xml
+fi
+
exec $(dirname $0)/run-class.sh org.apache.samza.container.SamzaContainer $@
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/bash/run-job.sh
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/bash/run-job.sh b/samza-shell/src/main/bash/run-job.sh
index 0605994..d43b556 100755
--- a/samza-shell/src/main/bash/run-job.sh
+++ b/samza-shell/src/main/bash/run-job.sh
@@ -16,4 +16,8 @@
# specific language governing permissions and limitations
# under the License.
+if [ -z "$SAMZA_LOG4J_CONFIG" ]; then
+ export SAMZA_LOG4J_CONFIG=file:$(dirname $0)/log4j-console.xml
+fi
+
exec $(dirname $0)/run-class.sh org.apache.samza.job.JobRunner $@
http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/7fd52e87/samza-shell/src/main/resources/log4j-console.xml
----------------------------------------------------------------------
diff --git a/samza-shell/src/main/resources/log4j-console.xml b/samza-shell/src/main/resources/log4j-console.xml
new file mode 100644
index 0000000..a6ee7ee
--- /dev/null
+++ b/samza-shell/src/main/resources/log4j-console.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+ 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.
+
+-->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n" />
+ </layout>
+ </appender>
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console"/>
+ </root>
+</log4j:configuration>