Skip to content

Commit

Permalink
[SPARK-50433][DOCS][TESTS] Fix confguring log4j2 guide docs for Spark…
Browse files Browse the repository at this point in the history
… on YARN and UT

### What changes were proposed in this pull request?

As title.

### Why are the changes needed?

SPARK-37814 (3.3.0) migrated logging system from log4j1 to log4j2, we should updated the docs as well.

### Does this PR introduce _any_ user-facing change?

Yes, docs are updated.

### How was this patch tested?

Review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#48981 from pan3793/SPARK-50433.

Lead-authored-by: Cheng Pan <[email protected]>
Co-authored-by: Cheng Pan <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
  • Loading branch information
2 people authored and dongjoon-hyun committed Dec 2, 2024
1 parent f382cdf commit ae4625c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object IntegrationTestUtils {

// Redirect server log into console
"--conf",
s"spark.driver.extraJavaOptions=-Dlog4j.configuration=$log4j2")
s"spark.driver.extraJavaOptions=-Dlog4j.configurationFile=$log4j2")
} else Seq.empty
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private[streaming] object StreamingExamples extends Logging {
// We first log something to initialize Spark's default logging, then we override the
// logging level.
logInfo("Setting log level to [WARN] for streaming example." +
" To override add a custom log4j.properties to the classpath.")
" To override add a custom log4j2.properties to the classpath.")
Configurator.setRootLevel(Level.WARN)
}
}
Expand Down
8 changes: 4 additions & 4 deletions docs/running-on-yarn.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ all environment variables used for launching each container. This process is use
classpath problems in particular. (Note that enabling this requires admin privileges on cluster
settings and a restart of all node managers. Thus, this is not applicable to hosted clusters).

To use a custom log4j configuration for the application master or executors, here are the options:
To use a custom log4j2 configuration for the application master or executors, here are the options:

- upload a custom `log4j.properties` using `spark-submit`, by adding it to the `--files` list of files
- upload a custom `log4j2.properties` using `spark-submit`, by adding it to the `--files` list of files
to be uploaded with the application.
- add `-Dlog4j.configuration=<location of configuration file>` to `spark.driver.extraJavaOptions`
- add `-Dlog4j.configurationFile=<location of configuration file>` to `spark.driver.extraJavaOptions`
(for the driver) or `spark.executor.extraJavaOptions` (for executors). Note that if using a file,
the `file:` protocol should be explicitly provided, and the file needs to exist locally on all
the nodes.
- update the `$SPARK_CONF_DIR/log4j.properties` file and it will be automatically uploaded along
- update the `$SPARK_CONF_DIR/log4j2.properties` file and it will be automatically uploaded along
with the other configurations. Note that other 2 options has higher priority than this option if
multiple options are specified.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object StreamingExamples extends Logging {
// We first log something to initialize Spark's default logging, then we override the
// logging level.
logInfo("Setting log level to [WARN] for streaming example." +
" To override add a custom log4j.properties to the classpath.")
" To override add a custom log4j2.properties to the classpath.")
Configurator.setRootLevel(Level.WARN)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class YarnClusterSuite extends BaseYarnClusterSuite {
}

test("running Spark in yarn-cluster mode displays driver log links") {
val log4jConf = new File(tempDir, "log4j.properties")
val log4jConf = new File(tempDir, "log4j2.properties")
val logOutFile = new File(tempDir, "logs")
Files.asCharSink(log4jConf, StandardCharsets.UTF_8).write(
s"""rootLogger.level = debug
Expand Down

0 comments on commit ae4625c

Please sign in to comment.