如何在 Intellij 的控制台上打印日志?

How to print logs on console in Intellij?

在 运行 进行单元测试时无法让日志显示在控制台上。相反,我每次 运行 单元测试时都会看到此消息 -

log4j:WARN No appenders could be found for logger. 
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

log4j.properties 包含这个 -

log4j.rootLogger=info, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender

我很确定这需要在 运行 配置中进行配置,但就是无法正常工作。真的很感激这方面的任何帮助。谢谢!

终于成功了!将此添加到 VM 选项 -

-Dlog4j.configuration=file:{path-to-properties-file}/log4j.properties

如 30thh 所述here

我已将它添加到我的默认单元测试配置中,但当前配置未拾取它。