【问题标题】:custom log using spark使用 spark 自定义日志
【发布时间】:2017-10-04 02:33:21
【问题描述】:

我正在尝试使用 spark-submit 配置自定义日志,这是我的配置:

driver:
-DlogsPath=/var/opt/log\
-DlogsFile=spark-submit-driver.log\
-Dlog4j.configuration=jar:file:../bin/myapp.jar!/log4j.properties\

spark.driver.extraJavaOptions -> -DlogsPath=/var/opt/log -DlogsFile=spark-submit-driver.log -Dlog4j.configuration=jar:file:../bin/myapp.jar!/log4j.properties

executor:
-DlogsPath=/var/opt/log\
-DlogsFile=spark-submit-executor.log\
-Dlog4j.configuration=jar:file:../bin/myapp.jar!/log4j.properties\

spark.executor.extraJavaOptions -> -DlogsPath=/var/opt/log -DlogsFile=spark-submit-executor.log -Dlog4j.configuration=jar:file:../bin/myapp.jar!/log4j.properties

spark-submit-drive.log 已创建并填充正常,但 spark-submit-executor.log 未装箱

有什么想法吗?

【问题讨论】:

  • 你的所有slave机器上都复制了log4j配置文件吗?
  • 解决了吗?

标签: log4j apache-spark


【解决方案1】:

请尝试使用

 --conf "spark.driver.extraJavaOptions=-Dlog4j.configuration=file:/Users/feng/SparkLog4j/SparkLog4jTest/target/log4j2.properties"

或

--文件

/Users/feng/SparkLog4j/SparkLog4jTest/target/log4j2.properties

以下提交它对我有用。

bin/spark-submit --class com.viaplay.log4jtest.log4jtest --conf "spark.driver.extraJavaOptions=-Dlog4j.configuration=file:/Users/feng/SparkLog4j/SparkLog4jTest/target/log4j2.properties"  --master local[*]  /Users/feng/SparkLog4j/SparkLog4jTest/target/SparkLog4jTest-1.0-jar-with-dependencies.jar

【讨论】:

    【解决方案2】:

    请在通过 spark submit 运行作业时尝试使用 log4j。

    例子:

    spark-submit -- class com.something.Driver 
    --master yarn \
    --driver-memory 1g \
    --executor-memory 1g \
    --driver-java-options '-Dlog4j.configuration=file:/absolute path to   log4j property file/log4j.properties' \
    --conf spark.executor.extraJavaOptions '-Dlog4j.configuration=file:/absolute path to log4j property file/log4j.properties' \
    jarfilename.jar
    

    注意:您必须使用 driver-java-options 和 conf spark.executor.extraJavaOptions 定义属性,也可以使用默认的 log4j.properties

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-15
      • 2017-12-13
      • 2018-09-17
      • 1970-01-01
      • 2016-05-09
      • 1970-01-01
      • 1970-01-01
      • 2016-08-18
      相关资源
      最近更新 更多