@user_unknown
Here are a few things you can check and confirm us
Verify the Path: Ensure that the path to the log4j2.properties
file is correct and accessible. You can try using a local path first to see if it works:
spark.conf.set("spark.driver.extraJavaOptions", "-Dlog4j.configurationFile=file:/path/to/log4j2.properties")
spark.conf.set("spark.executor.extraJavaOptions", "-Dlog4j.configurationFile=file:/path/to/log4j2.properties")
Check File Permissions: Make sure the log4j2.properties
file has the correct permissions and is readable by the Spark job.
Log4j2 Configuration: Double-check the content of your log4j2.properties
file. It should look something like this:
status = error
name = PropertiesConfig
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = warn
appenders = console
appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{ISO8601} [%t] %-5p %c %x - %m%n
rootLogger.level = warn
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT
Spark Configuration: Ensure that the Spark configuration is being applied correctly. You can print the Spark configuration to verify:
spark.conf.getAll.foreach(println)
Driver and Executor Logs: Check both driver and executor logs to see if there are any errors or warnings related to log4j configuration.
Alternative Configuration: If the above steps don't work, you can try setting the log level programmatically in your Spark application:
from pyspark.sql import SparkSession
import logging
spark = SparkSession.builder \
.appName("MyApp") \
.getOrCreate()
log4jLogger = spark._jvm.org.apache.log4j
logger = log4jLogger.LogManager.getLogger(__name__)
logger.setLevel(log4jLogger.Level.WARN)