spark-如何将spark的终端输出着色

vulvrdjw  于 2021-05-26  发布在  Spark
关注(0)|答案(0)|浏览(186)

当我运行spark submit时,它成功地工作了,但是输出没有着色。

(/Users/me/bai/conda-envs/spark-mllib-kmeans) me@my-mbp spark-mllib-kmeans % spark-submit spark-helloWorld.py
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/usr/local/Cellar/apache-spark/3.0.1/libexec/jars/spark-unsafe_2.12-3.0.1.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
20/12/22 12:18:33 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
20/12/22 12:18:34 INFO SparkContext: Running Spark version 3.0.1
20/12/22 12:18:34 INFO ResourceUtils: ==============================================================
20/12/22 12:18:34 INFO ResourceUtils: Resources for spark.driver:

20/12/22 12:18:34 INFO ResourceUtils: ==============================================================
20/12/22 12:18:34 INFO SparkContext: Submitted application: Simple App
...

我使用的是spark版本3.0.1:

(base) me@my-mbp spark-mllib-kmeans % spark-shell --version
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.spark.unsafe.Platform (file:/usr/local/Cellar/apache-spark/3.0.1/libexec/jars/spark-unsafe_2.12-3.0.1.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of org.apache.spark.unsafe.Platform
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Welcome to
      ____              __
     / __/__  ___ _____/ /__
    _\ \/ _ \/ _ `/ __/  '_/
   /___/ .__/\_,_/_/ /_/\_\   version 3.0.1
      /_/

Using Scala version 2.12.10, OpenJDK 64-Bit Server VM, 14.0.1
Branch HEAD
Compiled by user ubuntu on 2020-08-28T08:58:35Z
Revision 2b147c4cd50da32fe2b4167f97c8142102a0510d
Url https://gitbox.apache.org/repos/asf/spark.git
Type --help for more information.

我正在使用最新mac os上的默认mac终端程序:

% uname -a
Darwin my-mbp.lan 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec  2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64

我想看看不同颜色的日志语句级别(warn/info/error)。也许其他颜色的使用可以区分spark框架的输出和我的应用程序的输出。
考虑到框架级别的输出太多,并且由于框架问题而发出警告的噪音,我希望更好地使用颜色可以帮助我更快地扫描输出。
有没有简单的解决办法?
我在本机mac终端和ms-vsc集成终端中都看到了这种行为。
我看到了输出线:

Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties

我知道我可以在这里创建然后编辑log4j配置文件,所以也许我只需要log4j配置文件的配置来着色所有输出。

% cd $SPARK_HOME/conf                          
% cp log4j.properties.template log4j.properties

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题