¿Cómo desactivar el registro de INFORMACIÓN en Spark?


Instalé Spark usando la guía AWS EC2 y puedo iniciar el programa bien usando el script bin/pyspark para llegar al prompt de spark y también puedo hacer la quide de Inicio rápido con éxito.

Sin embargo, no puedo por mi vida averiguar cómo detener todo el registro detallado INFO después de cada comando.

He intentado casi todos los escenarios posibles en el siguiente código (comentando, configurando como DESACTIVADO) dentro de mi archivo log4j.properties en la carpeta conf en la que inicio la aplicación desde así como en cada nodo y nada está haciendo nada. Todavía recibo las instrucciones logging INFO imprimiéndose después de ejecutar cada instrucción.

Estoy muy confundido con cómo se supone que esto funciona.

#Set everything to be logged to the console log4j.rootCategory=INFO, console                                                                        
log4j.appender.console=org.apache.log4j.ConsoleAppender 
log4j.appender.console.target=System.err     
log4j.appender.console.layout=org.apache.log4j.PatternLayout 
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n

# Settings to quiet third party logs that are too verbose
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO

Aquí está mi classpath completo cuando uso SPARK_PRINT_LAUNCH_COMMAND:

Comando Spark: / Library/Java/JavaVirtualMachines / jdk1.8.0_05.jdk / Contenidos / Inicio / bin / java - cp :/root/spark-1.0.1-bin-hadoop2/conf:/root/spark-1.0.1-bin-hadoop2/conf:/root/spark-1.0.1-bin-hadoop2/lib/spark-assembly-1.0.1-hadoop2.2.0.jar: / root/spark-1.0.1-bin-hadoop2/lib / datanucleus-api-jdo-3.2.1.jar: / root/spark-1.0.1-bin-hadoop2/lib / datanucleus-core-3.2.2.jar: / root/spark-1.0.1-bin-hadoop2/lib / datanucleus-rdbms-3.2.1.frasco - XX: MaxPermSize = 128m-Djava.biblioteca.path= - Xms512m-Xmx512m org.apache.chispa.desplegar.SparkSubmit spark-shell class class org.apache.chispa.repl.Principal

Contenido de spark-env.sh:

#!/usr/bin/env bash

# This file is sourced when running various Spark programs.
# Copy it as spark-env.sh and edit that to configure Spark for your site.

# Options read when launching programs locally with 
# ./bin/run-example or ./bin/spark-submit
# - HADOOP_CONF_DIR, to point Spark towards Hadoop configuration files
# - SPARK_LOCAL_IP, to set the IP address Spark binds to on this node
# - SPARK_PUBLIC_DNS, to set the public dns name of the driver program
# - SPARK_CLASSPATH=/root/spark-1.0.1-bin-hadoop2/conf/

# Options read by executors and drivers running inside the cluster
# - SPARK_LOCAL_IP, to set the IP address Spark binds to on this node
# - SPARK_PUBLIC_DNS, to set the public DNS name of the driver program
# - SPARK_CLASSPATH, default classpath entries to append
# - SPARK_LOCAL_DIRS, storage directories to use on this node for shuffle and RDD data
# - MESOS_NATIVE_LIBRARY, to point to your libmesos.so if you use Mesos

# Options read in YARN client mode
# - HADOOP_CONF_DIR, to point Spark towards Hadoop configuration files
# - SPARK_EXECUTOR_INSTANCES, Number of workers to start (Default: 2)
# - SPARK_EXECUTOR_CORES, Number of cores for the workers (Default: 1).
# - SPARK_EXECUTOR_MEMORY, Memory per Worker (e.g. 1000M, 2G) (Default: 1G)
# - SPARK_DRIVER_MEMORY, Memory for Master (e.g. 1000M, 2G) (Default: 512 Mb)
# - SPARK_YARN_APP_NAME, The name of your application (Default: Spark)
# - SPARK_YARN_QUEUE, The hadoop queue to use for allocation requests (Default: ‘default’)
# - SPARK_YARN_DIST_FILES, Comma separated list of files to be distributed with the job.
# - SPARK_YARN_DIST_ARCHIVES, Comma separated list of archives to be distributed with the job.

# Options for the daemons used in the standalone deploy mode:
# - SPARK_MASTER_IP, to bind the master to a different IP address or hostname
# - SPARK_MASTER_PORT / SPARK_MASTER_WEBUI_PORT, to use non-default ports for the master
# - SPARK_MASTER_OPTS, to set config properties only for the master (e.g. "-Dx=y")
# - SPARK_WORKER_CORES, to set the number of cores to use on this machine
# - SPARK_WORKER_MEMORY, to set how much total memory workers have to give executors (e.g. 1000m, 2g)
# - SPARK_WORKER_PORT / SPARK_WORKER_WEBUI_PORT, to use non-default ports for the worker
# - SPARK_WORKER_INSTANCES, to set the number of worker processes per node
# - SPARK_WORKER_DIR, to set the working directory of worker processes
# - SPARK_WORKER_OPTS, to set config properties only for the worker (e.g. "-Dx=y")
# - SPARK_HISTORY_OPTS, to set config properties only for the history server (e.g. "-Dx=y")
# - SPARK_DAEMON_JAVA_OPTS, to set config properties for all daemons (e.g. "-Dx=y")
# - SPARK_PUBLIC_DNS, to set the public dns name of the master or workers

export SPARK_SUBMIT_CLASSPATH="$FWDIR/conf"
Author: user6910411, 2014-08-08

12 answers

Simplemente ejecute este comando en el directorio spark:

cp conf/log4j.properties.template conf/log4j.properties

Editar log4j. properties:

# Set everything to be logged to the console
log4j.rootCategory=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.err
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n

# Settings to quiet third party logs that are too verbose
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO

Sustitúyase en la primera línea:

log4j.rootCategory=INFO, console

Por:

log4j.rootCategory=WARN, console

Guarda y reinicia tu shell. Funciona para mí para Spark 1.1.0 y Spark 1.5.1 en OS X.

 127
Author: poiuytrez,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-09-07 16:12:26

Inspirado por el pyspark/tests.py Lo hice

def quiet_logs( sc ):
  logger = sc._jvm.org.apache.log4j
  logger.LogManager.getLogger("org"). setLevel( logger.Level.ERROR )
  logger.LogManager.getLogger("akka").setLevel( logger.Level.ERROR )

Llamar a esto justo después de crear SparkContext redujo las líneas stderr registradas para mi prueba del 2647 al 163. Sin embargo, al crear el propio SparkContext se registra 163, hasta

15/08/25 10:14:16 INFO SparkDeploySchedulerBackend: SchedulerBackend is ready for scheduling beginning after reached minRegisteredResourcesRatio: 0.0

Y no me queda claro cómo ajustarlos programáticamente.

 41
Author: FDS,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-08-25 15:46:47

Edite su archivo conf / log4j. properties y Cambie la siguiente línea:

   log4j.rootCategory=INFO, console

A

    log4j.rootCategory=ERROR, console

Otro enfoque sería :

Fireup spark-shell y escriba lo siguiente:

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

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

No verá ningún registro después de eso.

 31
Author: AkhlD,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-01-07 08:44:50
>>> log4j = sc._jvm.org.apache.log4j
>>> log4j.LogManager.getRootLogger().setLevel(log4j.Level.ERROR)
 30
Author: wannik,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-12-28 05:09:40

También puede establecer el nivel de registro en sus scripts con sc.setLogLevel("FATAL"). De los documentos :

Controla nuestro LogLevel. Esto anula cualquier configuración de registro definida por el usuario. Los niveles de registro válidos incluyen: ALL, DEBUG, ERROR, FATAL, INFO, OFF, TRACE, WARN

 22
Author: Galen Long,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-26 23:52:36

En Spark 2.0 también puede configurarlo dinámicamente para su aplicación usando setLogLevel :

    from pyspark.sql import SparkSession
    spark = SparkSession.builder.\
        master('local').\
        appName('foo').\
        getOrCreate()
    spark.sparkContext.setLogLevel('WARN')

En la consola pyspark, una sesión predeterminada spark ya estará disponible.

 14
Author: mdh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-09 10:07:50

Esto puede deberse a cómo Spark calcula su classpath. Mi corazonada es que el archivo log4j.properties de Hadoop aparece antes que el de Spark en la ruta de clases, evitando que tus cambios surtan efecto.

Si ejecuta

SPARK_PRINT_LAUNCH_COMMAND=1 bin/spark-shell

Entonces Spark imprimirá el classpath completo utilizado para lanzar el shell; en mi caso, veo

Spark Command: /usr/lib/jvm/java/bin/java -cp :::/root/ephemeral-hdfs/conf:/root/spark/conf:/root/spark/lib/spark-assembly-1.0.0-hadoop1.0.4.jar:/root/spark/lib/datanucleus-api-jdo-3.2.1.jar:/root/spark/lib/datanucleus-core-3.2.2.jar:/root/spark/lib/datanucleus-rdbms-3.2.1.jar -XX:MaxPermSize=128m -Djava.library.path=:/root/ephemeral-hdfs/lib/native/ -Xms512m -Xmx512m org.apache.spark.deploy.SparkSubmit spark-shell --class org.apache.spark.repl.Main

Donde /root/ephemeral-hdfs/conf está a la cabeza del classpath.

He abierto un problema [SPARK-2913] para solucionar esto en la próxima versión (debería tener un parche fuera pronto).

Mientras tanto, aquí hay un par de soluciones:

  • Añadir export SPARK_SUBMIT_CLASSPATH="$FWDIR/conf" a spark-env.sh.
  • Delete (or rename) /root/ephemeral-hdfs/conf/log4j.properties.
 12
Author: Josh Rosen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-08-08 00:11:41

Usé esto con Amazon EC2 con 1 maestro y 2 esclavos y Spark 1.2.1.

# Step 1. Change config file on the master node
nano /root/ephemeral-hdfs/conf/log4j.properties

# Before
hadoop.root.logger=INFO,console
# After
hadoop.root.logger=WARN,console

# Step 2. Replicate this change to slaves
~/spark-ec2/copy-dir /root/ephemeral-hdfs/conf/
 5
Author: oleksii,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-03-04 15:49:26

Spark 1.6.2:

log4j = sc._jvm.org.apache.log4j
log4j.LogManager.getRootLogger().setLevel(log4j.Level.ERROR)

Chispa 2.x:

spark.sparkContext.setLogLevel('WARN')

(spark siendo la SparkSession)

Alternativamente los métodos antiguos,

Cambie el nombre de conf/log4j.properties.template a conf/log4j.properties en el directorio de Spark.

En el log4j.properties, cambie log4j.rootCategory=INFO, console a log4j.rootCategory=WARN, console

Diferentes niveles de registro disponibles:

  • APAGADO (más específico, sin registro)
  • FATAL (más específico, pocos datos)
  • ERROR-Registro solo en caso de errores
  • WARN-Log solo en caso de Advertencias o Errores
  • INFO (Por defecto)
  • Pasos de detalles de registro de depuración (y todos los registros indicados anteriormente)
  • TRACE (menos específico, muchos datos)
  • TODOS (menos específicos, todos los datos)
 5
Author: Ani Menon,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-03-18 10:51:35

La forma en que lo hago es:

En la ubicación corro el script spark-submit do

$ cp /etc/spark/conf/log4j.properties .
$ nano log4j.properties

Cambie INFO al nivel de registro que desee y luego ejecute su spark-submit

 1
Author: user3827333,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-04-28 22:24:51

Si quieres seguir usando el logging (Logging facility para Python) puedes intentar dividir configuraciones para tu aplicación y para Spark:

LoggerManager()
logger = logging.getLogger(__name__)
loggerSpark = logging.getLogger('py4j')
loggerSpark.setLevel('WARNING')
 0
Author: santifinland,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-03 14:43:11

Simplemente agregue debajo de param a su comando spark-submit

--conf "spark.driver.extraJavaOptions=-Dlog4jspark.root.logger=WARN,console"

Esto anula temporalmente el valor del sistema solo para ese trabajo. Compruebe el nombre exacto de la propiedad (log4jspark.arraigar.logger aquí) del archivo log4j. properties.

Espero que esto ayude, ¡salud!

 0
Author: Gaurav Adurkar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-27 08:44:23