在Spark中使用log4j2

栏目: 服务器 · 发布时间: 8年前

内容简介:在Spark中使用log4j2

Spark默认使用的log4j 1.2,它的配置文件就在Spark conf文件下,比如说/etc/spark/conf/log4j.properties.

如果我们想要在spark中使用log4j2,则情况比较复杂了。首先需要事先将log4j2的jar包复制到master节点和全部slave节点上, 将它的路径加入到Spark的classpath中,然后将log4j2.xml文件加入到Spark conf中。

把log42.xml放到resources文件夹中,将log4j2的jar事先复制到各个节点的log4j2文件夹中,那么运行spark程序的command就是:

spark-submit --files "/home/hadoop/resources/log4j2.xml" 
--driver-java-options=-Dlog4j.configurationFile=resources/log4j2.xml 
--conf "spark.executor.extraJavaOptions=-Dlog4j.configurationFile=resources/log4j2.xml"
--conf "spark.driver.extraClassPath=:/home/hadoop/log4j2/*" 
--conf "spark.executor.extraClassPath=:/home/hadoop/log4j2/*"

–files 会将log4j2.xml文件复制到yarn每个executor工作目录下面。注意Spark会为复制的文件创建相应的文件夹, 所以在executor中读取文件的路径是 resources/log4j2.xml 而不是 ./log4j2.xml .


以上所述就是小编给大家介绍的《在Spark中使用log4j2》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Programming Python

Programming Python

Mark Lutz / O'Reilly Media / 2006-8-30 / USD 59.99

Already the industry standard for Python users, "Programming Python" from O'Reilly just got even better. This third edition has been updated to reflect current best practices and the abundance of chan......一起来看看 《Programming Python》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

URL 编码/解码
URL 编码/解码

URL 编码/解码