You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/01/05 02:57:05 UTC
[GitHub] [spark] LuciferYang commented on a change in pull request #35095: [SPARK-37805][TESTS] Refactor `TestUtils#configTestLog4j` method to use log4j2 api
LuciferYang commented on a change in pull request #35095:
URL: https://github.com/apache/spark/pull/35095#discussion_r778515785
##########
File path: core/src/main/scala/org/apache/spark/TestUtils.scala
##########
@@ -418,17 +419,18 @@ private[spark] object TestUtils {
}
/**
- * config a log4j properties used for testsuite
+ * config a log4j2 properties used for testsuite
*/
- def configTestLog4j(level: String): Unit = {
- val pro = new Properties()
- pro.put("log4j.rootLogger", s"$level, console")
- pro.put("log4j.appender.console", "org.apache.log4j.ConsoleAppender")
- pro.put("log4j.appender.console.target", "System.err")
- pro.put("log4j.appender.console.layout", "org.apache.log4j.PatternLayout")
- pro.put("log4j.appender.console.layout.ConversionPattern",
- "%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n")
- PropertyConfigurator.configure(pro)
+ def configTestLog4j2(level: String): Unit = {
+ val builder = ConfigurationBuilderFactory.newConfigurationBuilder()
+ val appenderBuilder = builder.newAppender("console", "CONSOLE")
+ .addAttribute("target", ConsoleAppender.Target.SYSTEM_ERR)
+ appenderBuilder.add(builder.newLayout("PatternLayout")
+ .addAttribute("pattern", "%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n"))
+ builder.add(appenderBuilder)
+ builder.add(builder.newRootLogger(s"$level").add(builder.newAppenderRef("console")))
+ val configuration = builder.build()
+ LogManager.getContext(false).asInstanceOf[LoggerContext].reconfigure(configuration)
Review comment:
I traced back to the original pr ([SPARK-3193](https://github.com/apache/spark/pull/2108)) it seems that `configTestLog4j ` is only added to help troubleshoot the failed UT on Jenkins.
I agree to remove this method directly, what do you think @dongjoon-hyun ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org