Repository: incubator-samza Updated Branches: refs/heads/0.7.0 a64bee927 -> cb00d7dee
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/cb00d7de Tree: http://git-wip-us.apache.org/repos/asf/incubator-samza/tree/cb00d7de Diff: http://git-wip-us.apache.org/repos/asf/incubator-samza/diff/cb00d7de Branch: refs/heads/0.7.0 Commit: cb00d7dee274e4deb4c77b83a2df7ad3588c396d Parents: a64bee9 Author: Yan Fang <[email protected]> Authored: Tue Jul 1 01:10:07 2014 -0700 Committer: Yan Fang <[email protected]> Committed: Tue Jul 1 01:10:07 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/cb00d7de/build.gradle ---------------------------------------------------------------------- diff --git a/build.gradle b/build.gradle index 8a7445d..0e0e0e3 100644 --- a/build.gradle +++ b/build.gradle @@ -186,13 +186,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 { @@ -208,6 +210,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 \ @@ -217,6 +220,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 @@ -225,6 +229,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/cb00d7de/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/cb00d7de/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 6105c81..18acc65 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 -kill $@ http://git-wip-us.apache.org/repos/asf/incubator-samza/blob/cb00d7de/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/cb00d7de/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 5aa34cd..3401046 100755 --- a/samza-shell/src/main/bash/run-class.sh +++ b/samza-shell/src/main/bash/run-class.sh @@ -58,9 +58,7 @@ fi if [ -z "$JAVA_OPTS" ]; then JAVA_OPTS="-Xmx768M -XX:+PrintGCDateStamps -Xloggc:$SAMZA_LOG_DIR/gc.log -Dsamza.log.dir=$SAMZA_LOG_DIR -Dsamza.container.name=$SAMZA_CONTAINER_NAME" - 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/cb00d7de/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/cb00d7de/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/cb00d7de/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>
