Apache Spark logging within Scala

后端 未结 7 2338
野趣味
野趣味 2020-12-12 19:18

I am looking for a solution to be able to log additional data when executing code on Apache Spark Nodes that could help investigate later some issues that might appear durin

7条回答
  •  Happy的楠姐
    2020-12-12 19:32

    You can use Akhil's solution proposed in
    https://www.mail-archive.com/user@spark.apache.org/msg29010.html. I have used by myself and it works.

    Akhil Das Mon, 25 May 2015 08:20:40 -0700
    Try this way:

    object Holder extends Serializable {      
       @transient lazy val log = Logger.getLogger(getClass.getName)    
    }
    
    
    val someRdd = spark.parallelize(List(1, 2, 3)).foreach { element =>
       Holder.log.info(element)
    }
    

提交回复
热议问题