How to stop INFO messages displaying on spark console?

后端 未结 20 3459
广开言路
广开言路 2020-11-22 13:40

I\'d like to stop various messages that are coming on spark shell.

I tried to edit the log4j.properties file in order to stop these message.

Her

20条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 14:17

    An interesting idea is to use the RollingAppender as suggested here: http://shzhangji.com/blog/2015/05/31/spark-streaming-logging-configuration/ so that you don't "polute" the console space, but still be able to see the results under $YOUR_LOG_PATH_HERE/${dm.logging.name}.log.

        log4j.rootLogger=INFO, rolling
    
    log4j.appender.rolling=org.apache.log4j.RollingFileAppender
    log4j.appender.rolling.layout=org.apache.log4j.PatternLayout
    log4j.appender.rolling.layout.conversionPattern=[%d] %p %m (%c)%n
    log4j.appender.rolling.maxFileSize=50MB
    log4j.appender.rolling.maxBackupIndex=5
    log4j.appender.rolling.file=$YOUR_LOG_PATH_HERE/${dm.logging.name}.log
    log4j.appender.rolling.encoding=UTF-8
    

    Another method that solves the cause is to observe what kind of loggings do you usually have (coming from different modules and dependencies), and set for each the granularity for the logging, while turning "quiet" third party logs that are too verbose:

    For instance,

        # Silence akka remoting
    log4j.logger.Remoting=ERROR
    log4j.logger.akka.event.slf4j=ERROR
    log4j.logger.org.spark-project.jetty.server=ERROR
    log4j.logger.org.apache.spark=ERROR
    log4j.logger.com.anjuke.dm=${dm.logging.level}
    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
    

提交回复
热议问题