sarutak commented on a change in pull request #26798: [SPARK-30167][REPL] Log4j
configuration for REPL can't override the root logger properly.
URL: https://github.com/apache/spark/pull/26798#discussion_r357506912
##########
File path: repl/src/test/scala/org/apache/spark/repl/ReplSuite.scala
##########
@@ -297,4 +299,110 @@ class ReplSuite extends SparkFunSuite with
BeforeAndAfterAll {
assertContains("successful", output)
}
+ test("SPARK-30167: Log4j configuration for REPL should override root logger
properly") {
+ val testConfiguration =
+ """
+ |# Set everything to be logged to the console
+ |log4j.rootCategory=INFO, console
+ |log4j.appender.console=org.apache.log4j.ConsoleAppender
+ |log4j.appender.console.target=System.err
+ |log4j.appender.console.layout=org.apache.log4j.PatternLayout
+ |log4j.appender.console.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss}
%p %c{1}: %m%n
+ |
+ |# Set the log level for this class to WARN same as the default
setting.
+ |log4j.logger.org.apache.spark.repl.Main=ERROR
+ |""".stripMargin
+
+ val log4jprops = Files.createTempFile("log4j.properties.d",
"log4j.properties")
+ Files.write(log4jprops, testConfiguration.getBytes)
+
+ val originalRootLogger = LogManager.getRootLogger
+ val originalRootAppender = originalRootLogger.getAppender("file")
+ val originalStderr = System.err
+ val originalReplThresholdLevel = Logging.sparkShellThresholdLevel
+
+ val replLoggerLogMessage = "Log level for REPL: "
+ val warnLogMessage1 = "warnLogMessage1 should not be output"
+ val errorLogMessage1 = "errorLogMessage1 should be output"
+ val infoLogMessage1 = "infoLogMessage2 should be output"
+ val infoLogMessage2 = "infoLogMessage3 should be output"
+
+ val out = try {
+ PropertyConfigurator.configure(log4jprops.toString)
Review comment:
Thanks. I've replaced it with absolute path.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]