From edd96307a10fe7e869bd39afb0cdbbc3a8f46c4d Mon Sep 17 00:00:00 2001 From: witgo Date: Mon, 7 Apr 2014 00:31:41 +0800 Subject: [PATCH] move to --- .../main/scala/org/apache/spark/Logging.scala | 3 +++ .../spark/sql/parquet/ParquetRelation.scala | 24 +++---------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/core/src/main/scala/org/apache/spark/Logging.scala b/core/src/main/scala/org/apache/spark/Logging.scala index 7423082e34f47..a632dcffdf681 100644 --- a/core/src/main/scala/org/apache/spark/Logging.scala +++ b/core/src/main/scala/org/apache/spark/Logging.scala @@ -20,6 +20,7 @@ package org.apache.spark import org.apache.log4j.{LogManager, PropertyConfigurator} import org.slf4j.{Logger, LoggerFactory} import org.slf4j.impl.StaticLoggerBinder +import org.slf4j.bridge.SLF4JBridgeHandler /** * Utility trait for classes that want to log data. Creates a SLF4J logger for the class and allows @@ -128,4 +129,6 @@ trait Logging { private object Logging { @volatile private var initialized = false val initLock = new Object() + SLF4JBridgeHandler.removeHandlersForRootLogger() + SLF4JBridgeHandler.install() } diff --git a/sql/core/src/main/scala/org/apache/spark/sql/parquet/ParquetRelation.scala b/sql/core/src/main/scala/org/apache/spark/sql/parquet/ParquetRelation.scala index bfedba1b91954..27917e223d923 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/parquet/ParquetRelation.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/parquet/ParquetRelation.scala @@ -81,32 +81,14 @@ private[sql] case class ParquetRelation(val path: String) private[sql] object ParquetRelation { - @volatile private var enabledLogForwarding = false - val initLock = new Object() - def enableLogForwarding() { // Note: Parquet does not use forwarding to parent loggers which // is required for the JUL-SLF4J bridge to work. Also there is // a default logger that appends to Console which needs to be // reset. - if (!enabledLogForwarding) { - initLock.synchronized { - if (!enabledLogForwarding) { - import org.slf4j.bridge.SLF4JBridgeHandler - import java.util.logging.Logger - import java.util.logging.LogManager - - if (!SLF4JBridgeHandler.isInstalled){ - LogManager.getLogManager.reset() - SLF4JBridgeHandler.install() - } - val parquetLogger = Logger.getLogger("parquet") - parquetLogger.getHandlers.foreach(parquetLogger.removeHandler) - parquetLogger.addHandler(new SLF4JBridgeHandler()) - enabledLogForwarding = true - } - } - } + val parquetLogger = java.util.logging.Logger.getLogger("parquet") + parquetLogger.getHandlers.foreach(parquetLogger.removeHandler) + if(parquetLogger.getLevel != null) parquetLogger.setLevel(null) } // The element type for the RDDs that this relation maps to.