Intellij中的ScalaTest不会打印出控制台消息

时间:2014-07-20 00:10:55

标签: scala intellij-idea scalatest

我正在运行使用ScalaTest的Spark测试。它们在命令行上使用以下命令非常健谈(除了-Dtest =显然被忽略 - 所有核心测试都在运行..):

 mvn -Pyarn -Phive test -pl core -Dtest=org.apache.spark.MapOutputTrackerSuite

有数千行输出,这是一种品味:

7:03:30.251 INFO org.apache.spark.scheduler.TaskSetManager: Finished TID 4417 in 23 ms on localhost (progress: 4/4)
17:03:30.252 INFO org.apache.spark.scheduler.TaskSchedulerImpl: Removed TaskSet 38.0, whose tasks have all completed, from pool 
17:03:30.252 INFO org.apache.spark.scheduler.DAGScheduler: Completed ResultTask(38, 3)
17:03:30.252 INFO org.apache.spark.scheduler.DAGScheduler: Stage 38 (apply at Transformer.scala:22) finished in 0.050 s
17:03:30.288 INFO org.apache.spark.ui.SparkUI: Stopped Spark web UI at http://localhost:4041
17:03:30.289 INFO org.apache.spark.scheduler.DAGScheduler: Stopping DAGScheduler

然而,在IJ中,只打印出测试通过/失败。那么如何在命令行上查看相同的繁琐的INFO级别输出?

1 个答案:

答案 0 :(得分:3)

log4j.properties不在类路径上。我解决这个问题的方式:

(a)在test / 资源文件夹中创建log4j.properties

(b)以下log4j.properties文件对我有用:

# Set everything to be logged to the file bagel/target/unit-tests.log
log4j.rootCategory=DEBUG, 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

# Ignore messages below warning level from Jetty, because it's a bit verbose
# Settings to quiet third party logs that are too verbose
log4j.logger.org.eclipse.jetty=WARN
log4j.logger.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO