今天创建一个sparkSQL工程,运行第一个sparkSQL程序控制台打印了许多冗余的info级别的日志信息

解决方案:在工程项目的资源resources目录下配置一下log4j日志配置文件
log4j.rootCategory=ERROR, 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
# Set the default spark-shell log level to ERROR. When running the spark-shell, the # log level for this class is used to overwrite the root logger's log level, so that
# the user can have different defaults for the shell and regular Spark apps.
log4j.logger.org.apache.spark.repl.Main=ERROR
# Settings to quiet third party logs that are too verbose
log4j.logger.org.spark_project.jetty=ERROR
log4j.logger.org.spark_project.jetty.util.component.AbstractLifeCycle=ERROR
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=ERROR
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=ERROR
log4j.logger.org.apache.parquet=ERROR
log4j.logger.parquet=ERROR
# SPARK-9183: Settings to avoid annoying messages when looking up nonexistent UDFs in SparkSQL with Hive support
log4j.logger.org.apache.hadoop.hive.metastore.RetryingHMSHandler=FATAL
log4j.logger.org.apache.hadoop.hive.ql.exec.FunctionRegistry=ERROR
在创建SparkSQL工程并运行程序时,控制台输出了大量的info级别日志信息。为了解决这个问题,可以在工程的resources目录下配置log4j日志配置文件,将rootCategory设置为ERROR级别,限制日志输出。同时,针对特定类如SparkREPL和Jetty等,也设置为ERROR级别以减少冗余信息。这样可以有效地减少控制台的日志打印,提高日志的可读性。
2万+

被折叠的 条评论
为什么被折叠?



