gpt4 book ai didi

scala - 以编程方式减少 spark shell 中的日志

转载 作者:行者123 更新时间:2023-12-02 06:33:06 25 4
gpt4 key购买 nike

我可以通过删除所有 "INFO" 标志以编程方式减少 spark shell 中的日志吗?它正在向我的窗口发送垃圾邮件,我无法分析实际输出例如:

15/01/09 12:23:02 INFO Executor: Finished task 0.0 in stage 0.0 (TID 0). 649 bytes result sent to driver
15/01/09 12:23:02 INFO TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 500 ms on localhost (1/1)
15/01/09 12:23:02 INFO DAGScheduler: Stage 0 (count at MainApp.scala:31) finished in 0.520 s
15/01/09 12:23:02 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
15/01/09 12:23:02 INFO DAGScheduler: Job 0 finished: count at MainApp.scala:31, took 0.639191 s

寻找任何替代品(如果有)!

最佳答案

这会删除大部分信息消息(虽然不是全部)

import org.apache.log4j.{Level, Logger}
// ...
val level = Level.WARN
Logger.getLogger("org").setLevel(level)
Logger.getLogger("akka").setLevel(level)

或者作为 util 方法:

def setLogLevel(level: String): Unit = {
setLogLevel(Level.toLevel(level, Level.INFO))
}

def setLogLevel(level: Level): Unit = {
Logger.getLogger("org").setLevel(level)
Logger.getLogger("akka").setLevel(level)
}

关于scala - 以编程方式减少 spark shell 中的日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27859549/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com