3

I've tried to disable INFO messages in Spark in a particular application, but I couldn't, I was still seeing it.

The code I tried was from here: (How to stop messages displaying on spark console? )

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

Logger.getLogger("org").setLevel(Level.OFF)
Logger.getLogger("akka").setLevel(Level.OFF)`

I've also edited the log4j file in Spark installation dir, putting this:

log4j.rootCategory=WARN, console

And it worked! But it is not the solution that I wanted... I would like to disable the INFO message from each application.

Any comments? Thank you!!

mjbsgll
  • 722
  • 9
  • 24

1 Answers1

3

You must do this:

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

Logger.getLogger("org").setLevel(Level.OFF)
Logger.getLogger("akka").setLevel(Level.OFF)

before creating a SparkContext.
Do something like this:

Logger.getLogger("org").setLevel(Level.OFF)
Logger.getLogger("akka").setLevel(Level.OFF)
val sc = new SparkContext(conf)

Also, you can use getRootLogger method:

Logger.getRootLogger().setLevel(Level.ERROR)
Yehor Krivokon
  • 837
  • 5
  • 17