Log4j2 - Spring 未找到测试记录器

Log4j2 - Spring Test logger not found

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

我的层次结构是这样的

App -> src -> main -> resources -> log4j.xml
App -> src -> test -> test-resources -> log4j.xml

我的测试class 使用此配置运行

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath*:**/beans-common.xml", "classpath:/beans.xml", "classpath:/dao.xml",
    "classpath:/service-config.xml"})

知道吗,我在这里缺少什么?

请将配置文件重命名为 log4j2.xmllog4j2-test.xml。 如果这些文件在类路径中,Log4j2 将找到它们。 (它会先寻找测试版。)

您的配置文件名为 log4j.xml(它们缺少“2”)。