如何更改Spark中的日志级别? [英] How to change log level in spark?
本文介绍了如何更改Spark中的日志级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了所有这些方法,但没有任何效果:
I tried all this methods and nothing works :
在log4j文件中-
log4j.logger.org=OFF
log4j.rootCategory=ERROR, console
log4j.rootCategory=OFF, console
在代码中:
#option 1
Logger.getLogger("org.apache.spark").setLevel(Level.OFF)
#option 2
sparkContext.setLogLevel("OFF")
#option 3
val rootLogger: Logger = Logger.getRootLogger()
rootLogger.setLevel(Level.OFF)
是的,也尝试过将其放在spark上下文对象之前,但似乎没有任何效果.
我想念什么?
还是还有另一种设置日志级别的方法?
And yes also tried by putting it after spark context object also before.Nothing seems working.
What am I missing ?
Or Is there another way to set the log levels ?
推荐答案
您可以从一开始就找到这些日志,这意味着我们需要通过logback而不是log4j来设置日志配置.
You could find these logs from the start, which means we need to set log config via logback instead of log4j.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/linzi/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/linzi/.m2/repository/org/slf4j/slf4j-log4j12/1.7.26/slf4j-log4j12-1.7.26.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
添加为logback.xml设置,如下所示:
Add as logback.xml setting as below:
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>
<logger name="com.mkyong" level="debug" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<root level="error">
<appender-ref ref="CONSOLE"/>
</root>
这篇关于如何更改Spark中的日志级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文