You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-37805][TESTS] Refactor TestUtils#configTestLog4j method to use log4j2 api
### What changes were proposed in this pull request?
SPARK-37795 add a scalastyle rule to ban `org.apache.log4j` imports, but there is still one place to retain the imports of `org.apache.log4j` in `o.a.spark.TestUtils`.
This pr refactor `configTestLog4j` method in `o.a.spark.TestUtils` to use log4j2 api and let the log behavior using log4j2.x be the same as that using log4j1.x before. In fact, the `configTestLog4j` method behavior before this pr is invalid because `PropertyConfigurator.configure` method in `org.apache.logging.log4j:log4j-1.2-api` is an empty method as follows:
https://github.com/apache/logging-log4j2/blob/491a0b3787975b6fc95b6a8cb3da76dc7517c65f/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java#L39-L47
Another change of this pr is rename the method name from `configTestLog4j` to `configTestLog4j2`.
### Why are the changes needed?
Clean up the `org.apache.log4j` imports left in Spark internal and let `configTestLog4j` method behavior keep consistent between log4j1.x and log4j2.x.
### Does this PR introduce _any_ user-facing change?
The `configTestLog4j` method in `TestUtils` rename to `configTestLog4j2`
### How was this patch tested?
- Pass the Jenkins or GitHub Action
- Manual test
Run the test cases using `configTestLog4j` method in the following 3 scenarios:
1. without this pr to test log4j2.x
2. with this pr to test log4j2.x
3. run `git reset --hard 1922798` to test log4j1.x
For example `WholeStageCodegenSparkSubmitSuite`, run
```
mvn clean install -DskipTests -pl sql/core -am
mvn test -pl sql/core -Dtest=none -DwildcardSuites=org.apache.spark.sql.execution.WholeStageCodegenSparkSubmitSuite
```
Scenario 1 does not print any logs to the console, scenario 2 and scenario 3 will print similar logs to the console
Closesapache#35095 from LuciferYang/refactor-configTestLog4j.
Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
(cherry picked from commit f3eedaf)
0 commit comments