如何停止在火花控制台上显示INFO消息?

如何停止在火花控制台上显示INFO消息?

我想停止火花壳上的各种消息。


我试图编辑该log4j.properties文件以阻止这些消息。


这是内容 log4j.properties


# Define the root logger with appender file

log4j.rootCategory=WARN, console

log4j.appender.console=org.apache.log4j.ConsoleAppender

log4j.appender.console.target=System.err

log4j.appender.console.layout=org.apache.log4j.PatternLayout

log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n


# Settings to quiet third party logs that are too verbose

log4j.logger.org.eclipse.jetty=WARN

log4j.logger.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR

log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO

log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO

但是消息仍在控制台上显示。


以下是一些示例消息


15/01/05 15:11:45 INFO SparkEnv: Registering BlockManagerMaster

15/01/05 15:11:45 INFO DiskBlockManager: Created local directory at /tmp/spark-local-20150105151145-b1ba

15/01/05 15:11:45 INFO MemoryStore: MemoryStore started with capacity 0.0 B.

15/01/05 15:11:45 INFO ConnectionManager: Bound socket to port 44728 with id = ConnectionManagerId(192.168.100.85,44728)

15/01/05 15:11:45 INFO BlockManagerMaster: Trying to register BlockManager

15/01/05 15:11:45 INFO BlockManagerMasterActor$BlockManagerInfo: Registering block manager 192.168.100.85:44728 with 0.0 B RAM

15/01/05 15:11:45 INFO BlockManagerMaster: Registered BlockManager

15/01/05 15:11:45 INFO HttpServer: Starting HTTP Server

15/01/05 15:11:45 INFO HttpBroadcast: Broadcast server star

我该如何阻止这些?


沧海一幻觉
浏览 487回答 3
3回答

一只名叫tom的猫

刚开始spark-shell打字后;sc.setLogLevel("ERROR")在Spark 2.0中:spark = SparkSession.builder.getOrCreate()spark.sparkContext.setLogLevel("ERROR")

扬帆大鱼

建议修改.conf文件。以下代码解决了我的问题:1)import org.apache.log4j.{Level, Logger}在导入部分添加2)在创建spark上下文对象后添加以下行,即val sc = new SparkContext(conf):val rootLogger = Logger.getRootLogger()rootLogger.setLevel(Level.ERROR)
打开App,查看更多内容
随时随地看视频慕课网APP