Skip to content

Commit 1539ecd

Browse files
jinsoojinsoo
authored andcommitted
fix: suppress noisy Spark log
1 parent 46e0760 commit 1539ecd

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

conf/log4j2-spark-quiet.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Spark 로그 억제 (SPARK_LOG.md)
2+
# - NativeCodeLoader WARN → ERROR (Hadoop native-hadoop 메시지 제거)
3+
# - rootLogger WARN (불필요한 INFO/WARN 감소)
4+
5+
rootLogger.level = warn
6+
rootLogger.appenderRef.stdout.ref = console
7+
8+
appender.console.type = Console
9+
appender.console.name = console
10+
appender.console.target = SYSTEM_ERR
11+
appender.console.layout.type = PatternLayout
12+
appender.console.layout.pattern = %d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n%ex
13+
14+
# Hadoop NativeCodeLoader WARN 제거 (Unable to load native-hadoop library...)
15+
logger.nativecode.name = org.apache.hadoop.util.NativeCodeLoader
16+
logger.nativecode.level = error

src/comparison_pipeline.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,27 @@
2727

2828

2929
def _get_spark() -> "SparkSession":
30-
"""SparkSession lazy 초기화 (프로세스당 1회)."""
30+
"""SparkSession lazy 초기화 (프로세스당 1회). SPARK_LOG.md 반영: 진행바·Hadoop WARN 억제."""
3131
global _spark_session
3232
if _spark_session is None and SPARK_AVAILABLE:
33-
_spark_session = (
33+
builder = (
3434
SparkSession.builder.appName("comparison_pipeline")
3535
.master("local[6]")
3636
.config("spark.driver.memory", "2g")
3737
.config("spark.driver.bindAddress", "127.0.0.1")
38-
.getOrCreate()
38+
.config("spark.ui.showConsoleProgress", "false")
3939
)
40+
_log4j_path = os.path.join(
41+
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
42+
"conf",
43+
"log4j2-spark-quiet.properties",
44+
)
45+
if os.path.exists(_log4j_path):
46+
builder = builder.config(
47+
"spark.driver.extraJavaOptions",
48+
f"-Dlog4j.configurationFile=file:{os.path.abspath(_log4j_path)}",
49+
)
50+
_spark_session = builder.getOrCreate()
4051
logger.debug("SparkSession 생성 완료")
4152
return _spark_session
4253

0 commit comments

Comments
 (0)