我正在尝试在我的 Spark 应用程序(以及驱动程序中)中使用自定义
log4j2.properties
文件
我的 Spark 版本是最新的:
3.5.0
我按照这个问题的答案,将其适应log4j2
所以基本上我将其添加到
spark-submit
--conf 'spark.driver.extraJavaOptions=-Dlog4j.configurationFile=log4j2.properties'
--conf 'spark.executor.extraJavaOptions=-Dlog4j.configurationFile=log4j2.properties'
--files 'path/to/log4j2.properties'
在驱动程序日志中,我可以看到 JVM 参数:
-Dlog4j.configurationFile=log4j2.properties
但奇怪的是,在日志(stderr)中,我可以看到:
Using Spark's default log4j profile: org/apache/spark/log4j2-defaults.properties
[...]
23/09/29 14:04:08 INFO SparkContext: Added file file:///path/to/log4j2.properties at spark://server:port/files/log4j2.properties with timestamp 1695989047843
记录器初始化后
log4j2.properties
文件被复制,因此,它不起作用,我的文件不被考虑在内。有什么想法吗?
3.3.0
)
似乎Dlog4j.configuration
是
Dlog4j2.configurationFile
的旧版本,以下语法对我有用:--files "./shared/code/log4j.properties" \
--conf "spark.driver.extraJavaOptions=-Dlog4j2.configurationFile=file:./shared/code/log4j.properties" \
--conf "spark.executor.extraJavaOptions=-Dlog4j2.configurationFile=file:./shared/code/log4j.properties" \
shared
是docker容器中的一个安装文件夹,我在其中以客户端模式运行spark集群。