java - 如何在 IntelliJ 中控制 Spark 日志记录
问题描述
我通常从 JUnit 运行东西,但我也尝试过运行main
它并没有什么区别。
我已经阅读了近两打 SO 问题、博客文章和文章,并尝试了几乎所有方法来让 Spark 停止记录这么多。
我尝试过的事情:
log4j.properties
在资源文件夹中(在src
和test
)spark-submit
添加log4j.properties
失败的“ error: missing application resources
”Logger.getLogger("com").setLevel(Level.WARN);
Logger.getLogger("org").setLevel(Level.WARN);
Logger.getLogger("akka").setLevel(Level.WARN);
Logger.getRootLogger().setLevel(Level.WARN);
spark.sparkContext().setLogLevel("WARN");
在另一个项目中,我让日志保持安静:
Logger.getLogger("org").setLevel(Level.WARN);
Logger.getLogger("akka").setLevel(Level.WARN);
但它在这里不起作用。
我如何创建我的 SparkSession:
SparkSession spark = SparkSession
.builder()
.appName("RS-LDA")
.master("local")
.getOrCreate();
如果您想查看更多我的代码,请告诉我。
谢谢
解决方案
我正在使用 IntelliJ 和 Spark,这对我有用:
Logger.getRootLogger.setLevel(Level.ERROR)
您也可以更改 Log Spark 配置。
$ cd SPARK_HOME/conf
$ gedit log4j.properties.template
# find this lines in the file
# Set everything to be logged to the console
log4j.rootCategory=INFO, console
and change to ERROR
log4j.rootCategory=ERROR, console
In this file you have other options tho change too
# Set the default spark-shell log level to WARN. 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=WARN
# Settings to quiet third party logs that are too verbose
.....
And finally rename the log4j.properties.template file
$ mv log4j.properties.template log4j.properties
您可以点击此链接进行进一步配置:
或者这个也是:
推荐阅读
- windows - 适用于 Windows 的 Ansible
- mysql - 此 SQL/关系数据库模式的名称?(完全持久化的列表?)
- firebase - 在 Flutter 应用程序中获取空值(Firestore 查询结果)
- powershell - 通过 OUTLOOK SMTP 服务器发送电子邮件的脚本
- python - 按嵌套索引对两个不同长度的列表进行排序
- docker - 当我尝试在 ubuntu:18.04 中移动 /etc/resolv.conf 时出现“设备或资源繁忙”。怎么修?
- c# - 隐藏应用层的中间表
- reactjs - 如何在另一个类组件中使用 material-ui lab - checkboxestag 组件?
- apache-spark - spark读取textFile和csv之间的区别
- javascript - 重新导出时导入无法识别导出的名称