Are Log Messages too Verbose in Spark Shell? Then Fix it!

Spark’s Interactive Shell (spark-shell/pyspark) is one of the great features offered by Apache Spark.

You can find advantages of Spark’s interactive shell below:

  • Analysing Data Interactively - No need to create, build and deploy applications
  • Learning Spark API - One can easily practice, learn and master the API
  • Debugging Code - Debugging some part of Spark Application code is easy with Interactive Shell

This looks really amazing! But most of the people feel discomfort with logs produced at the time of Spark code is executed in Interactive Shell

For the sake of good, Spark allows you to TURN OFF the logs. To achieve that you need to execute the following commands as soon as you launches the respective Spark shell.(You are flexible to choose log level between INFO, WARN, ERROR etc)

Scala Users:



import org.apache.log4j.Logger
import org.apache.log4j.Level

Python Users:



log4j =

P.S: It is always a good practice to observe and understand the logs


Can we set the Spark shell to WARN globally? The INFO messages we see in spark-shell are mostly unecessary.