raydp icon indicating copy to clipboard operation
raydp copied to clipboard

Setting log level in RayDP

Open gbraes opened this issue 2 years ago • 5 comments

In the recent version of Ray/RayDP 1.12/0.4.2 I am getting a lot of INFO logs. I am trying to disable them. Does Anyone know how to do that when using RayDP? sc.sparkContext.setLogLevel('WARN') does not work.

gbraes avatar Apr 26 '22 17:04 gbraes

I have also tried to disable it using logging_level='warn' in Ray.init

import ray
import raydp
from pyspark import SparkContext, SparkConf, SQLContext


configs = {}
ray.init(logging_level='warn') 
sc = raydp.init_spark(app_name='RayDP stream Example', num_executors=2, executor_cores=2, executor_memory='4GB',configs=configs)

It keeps giving you a lot of INFO logs.

Ray: 1.12 RayDP: 0.4.2 Pyspark: 3.2.1 Java version: Java 11 (build 11.0.15+10-Ubuntu-0ubuntu0.20.02.1)

gbraes avatar Apr 27 '22 11:04 gbraes

Hi, It seems like only under ray.init('auto', logging_level='warn') and add configs={"spark.driver.extraJavaOptions": "-Dlog4j.configuration=/home/lzhi/log4j.properties"} in raydp.init_spark can the logging level be set. We'll look into it.

Thanks for raising this issue

kira-lin avatar Apr 28 '22 02:04 kira-lin

Hi @gbraes, This problem is ray's jar wraps slf4j, while pyspark/jars/ also contains slf4j. When spark starts, we need to add ray.jar to classpath, so it'll find two bindings, and this is annoying. As I tested, if you remove the slf4j jar from pyspark/jars/, and set the configs={"spark.driver.extraJavaOptions": "-Dlog4j.configuration=/home/lzhi/log4j.properties"}, most logging will go away.

kira-lin avatar May 05 '22 08:05 kira-lin

Hi @kira-lin , I have tested using my own log4j.properties file where I set up the log level to warn. After adding that extra java option where I point to that file, as you mentioned in the config when loading raydp, and now it works!. So, now I don't get the annoying and verbose INFO logs. Thanks!

However, I did not need to remove slf4j jar from pyspark.

gbraes avatar May 05 '22 11:05 gbraes

That is also possible, because as slf4j says, it's somehow random(up to jvm) to decide which one to load when multiple jars is found in classpath. Glad to hear that you are able to turn it off.

kira-lin avatar May 06 '22 01:05 kira-lin

This has been improved in RayDP 0.5.0. Please see https://github.com/oap-project/raydp/blob/master/doc/spark_on_ray.md#logging

carsonwang avatar Sep 09 '22 08:09 carsonwang

This has been improved in RayDP 0.5.0. Please see https://github.com/oap-project/raydp/blob/master/doc/spark_on_ray.md#logging

@carsonwang Thanks a lot!

gebraes avatar Sep 09 '22 13:09 gebraes