浏览代码

[spark] Switch to logback

Erick Tryzelaar 11 年之前
父节点
当前提交
66b99dc

+ 8 - 0
apps/spark/java/livy-core/pom.xml

@@ -13,6 +13,14 @@
     <artifactId>livy-core</artifactId>
     <packaging>jar</packaging>
 
+    <dependencies>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.1.2</version>
+        </dependency>
+    </dependencies>
+
     <build>
         <plugins>
 

+ 3 - 2
apps/spark/java/livy-core/src/main/scala/com/cloudera/hue/livy/Logging.scala

@@ -1,8 +1,9 @@
 package com.cloudera.hue.livy
 
+import org.slf4j.LoggerFactory
+
 trait Logging {
-  val loggerName = this.getClass.getName
-  lazy val logger = LoggerFactory.getLogger(loggerName)
+  lazy val logger = LoggerFactory.getLogger(this.getClass)
 
   def debug(message: => Any) = {
     if (logger.isDebugEnabled) {

+ 12 - 0
apps/spark/java/livy-repl/src/main/resources/logback.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>

+ 6 - 1
apps/spark/java/livy-yarn/pom.xml

@@ -72,7 +72,6 @@
             <version>${scala.version}</version>
         </dependency>
 
-
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-webapp</artifactId>
@@ -97,6 +96,12 @@
             </exclusions>
         </dependency>
 
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.1.2</version>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 4 - 4
apps/spark/java/livy-yarn/src/main/bash/run-class.sh

@@ -9,7 +9,7 @@ cd $home_dir
 HADOOP_YARN_HOME="${HADOOP_YARN_HOME:-$HOME/.livy}"
 HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_YARN_HOME/conf}"
 CLASSPATH="$HADOOP_CONF_DIR:$base_dir/lib/*"
-DEFAULT_LOG4J_FILE="$base_dir/resources/log4j.properties"
+DEFAULT_LOGBACK_FILE="$base_dir/resources/logback.xml"
 
 #for file in $base_dir/lib/*.[jw]ar;
 #do
@@ -33,10 +33,10 @@ function check_and_enable_64_bit_mode {
 # Check if 64 bit is set. If not - try and set it if it's supported
 [[ $JAVA_OPTS != *-d64* ]] && check_and_enable_64_bit_mode
 
-# Check if log4j configuration is specified. If not - set to lib/log4j.xml
-[[ $JAVA_OPTS != *-Dlog4j.configuration* && -f $DEFAULT_LOG4J_FILE ]] && JAVA_OPTS="$JAVA_OPTS -Dlog4j.configuration=file:$DEFAULT_LOG4J_FILE"
+# Check if logback configuration is specified. If not - set to resources/logback.xml
+[[ $JAVA_OPTS != *-Dlogback.configuration* && -f $DEFAULT_LOGBACK_FILE ]] && JAVA_OPTS="$JAVA_OPTS -Dlogback.configuration=file:$DEFAULT_LOGBACK_FILE"
 
-JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5006"
+JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5006"
 
 echo $JAVA $JAVA_OPTS -cp "$CLASSPATH" "$@"
 exec $JAVA $JAVA_OPTS -cp "$CLASSPATH" "$@"

+ 0 - 30
apps/spark/java/livy-yarn/src/main/resources/log4j.properties

@@ -1,30 +0,0 @@
-#
-# 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.
-#
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.err
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p %c{1} - %m%n
-
-log4j.rootLogger=INFO, stdout
-
-# Switching off most of Apache DS logqing which is QUITE verbose
-log4j.logger.org.apache.directory=OFF
-log4j.logger.org.apache.directory.server.kerberos=INFO, stdout
-log4j.additivity.org.apache.directory=false
-log4j.logger.net.sf.ehcache=INFO, stdout

+ 12 - 0
apps/spark/java/livy-yarn/src/main/resources/logback.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>