简体   繁体   English

Maven - ERROR StatusLogger找不到log4j2配置文件

[英]Maven - ERROR StatusLogger No log4j2 configuration file found

When running mvn verify I am getting below message: 运行mvn verify我收到以下消息:

在此输入图像描述

I already put the log4j2.xml under src/test/resources (but not in src/main/resources because I do not want it to ship with actual app) as suggested here to no avail. 我已经将log4j2.xml放在src/test/resources (但不是在src/main/resources因为我不希望它与实际应用程序一起提供),因为这里建议无济于事。

在此输入图像描述

The HTML report is generated, the log file is written, and the build is successful as seen above. 生成HTML报告,编写日志文件,并且构建成功,如上所示。 I am unsure where the error is coming from. 我不确定错误来自哪里。

According http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration adding log4j2.xml to classpath should help. 根据http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfigurationlog4j2.xml添加到classpath应该有所帮助。

If a JSON file cannot be located the XML ConfigurationFactory will try to locate log4j2.xml on the classpath. 如果找不到JSON文件,XML ConfigurationFactory将尝试在类路径上找到log4j2.xml。

So if you still get ERROR message problem not with your sources. 因此,如果您仍然收到ERROR消息问题,请不要使用您的来源。 It looks like problem in maven-cucumber-reporting plugin. 它看起来像maven-cucumber-reporting插件中的问题。 As described here http://maven.apache.org/guides/mini/guide-maven-classloading.html 如此处所述http://maven.apache.org/guides/mini/guide-maven-classloading.html

Please note that the plugin classloader does neither contain the dependencies of the current project nor its build output. 请注意,插件类加载器既不包含当前项目的依赖项,也不包含其构建输出。

If maven plugin cannot find any log4j configuration in its own classpath (which is not including your sources/resources) you will see error messages. 如果maven插件在其自己的类路径中找不到任何log4j配置(不包括您的源/资源),您将看到错误消息。 So yes, the only solution wait for release with fix https://github.com/damianszczepanik/cucumber-reporting/issues/675 所以是的,唯一的解决方案是等待发布修复https://github.com/damianszczepanik/cucumber-reporting/issues/675

You use the latest Cucumber version 3.15.0 (at the time of writing this). 您使用最新的Cucumber版本3.15.0(在撰写本文时)。 Your problem was resolved as issue #675 . 您的问题已解决为问题#675 There was a commit from a pull request meant to fix this problem, but probably you have to wait until the next version is released in order to profit from it - or build a snapshot version locally and see if it also fixes the problem for you. 来自拉取请求提交旨在解决此问题,但可能您必须等到下一个版本发布才能从中获利 - 或者在本地构建快照版本并查看它是否也为您解决了问题。

Run -> Run Configurations -> Classpath -> User entries -> Advanced Optiones -> Add Folders -> Then add your folder,in your case src/test/resources -> apply 运行 - >运行配置 - >类路径 - >用户条目 - >高级选项 - >添加文件夹 - >然后添加你的文件夹,在你的情况下src / test / resources - > apply

It must work now :D 它现在必须工作:D

You are receiving this error because cucumber or its dependencies are using log4j for logging and since there is no log4j configuration file so log4j is printing such message. 您收到此错误是因为cucumber或其依赖项正在使用log4j进行日志记录,并且由于没有log4j配置文件,因此log4j正在打印此类消息。

If there is no log4j configuration file, log4j uses configuration similar to below - 如果没有log4j配置文件, log4j使用类似于下面的配置 -

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configuration>

<Configuration status="warn" name="xml_configuration">

    <Appenders>
        <Console name="consoleLogger" target="SYSTEM_OUT">
            <PatternLayout
                pattern="[%level] %m%n" />
        </Console>
    </Appenders>

    <Loggers>
        <Root level="error" additivity="false">
            <appender-ref ref="consoleLogger" />
        </Root>
    </Loggers>
</Configuration>

Adding above configuration in /src/main/resources/log4j2.xml will have same result as having no log4j2.xml file. /src/main/resources/log4j2.xml添加上述配置与没有log4j2.xml文件的结果相同。

Another way to try is to pass log4j2.xml file to maven directly without putting it in project classpath. 另一种尝试方法是将log4j2.xml文件直接传递给maven,而不将其放在项目类路径中。 Something like below - 像下面的东西 -

set MAVEN_OPTS="-Dlog4j.configurationFile=file:///path/to/log4j2.xml"
mvn verify

according to their documentation, you can use 'joranConfigurator' and load the configuration from a specified file 根据他们的文档,您可以使用'joranConfigurator'并从指定的文件加载配置

documentation link 文档链接

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 log4j2错误StatusLogger找不到log4j2配置文件和ResourceBundle错误 - log4j2 ERROR StatusLogger No log4j2 configuration file found and ResourceBundle error 错误StatusLogger找不到log4j2配置文件。 使用默认配置:仅将错误记录到控制台 - ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console PreBuiltTransportClient 写入消息:错误 StatusLogger 找不到 log4j2 配置文件 - PreBuiltTransportClient Writes Message : ERROR StatusLogger No log4j2 configuration file found 错误 StatusLogger 未找到 log4j2 配置文件。 在更新 Struts 2.5.12 版本时 - ERROR StatusLogger No log4j2 configuration file found. While updating the version 2.5.12 of Struts log4j2 - StatusLogger未找到Log4j 2配置文件。 使用默认配置 - log4j2 - StatusLogger No Log4j 2 configuration file found. Using default configuration 错误StatusLogger找不到log4j2配置文件。 使用ANT目标进行编译时使用默认配置 - ERROR StatusLogger No log4j2 configuration file found. Using default configuration while compiling using ANT target 解决方法-错误StatusLogger找不到Log4j 2配置文件 - How to solve - ERROR StatusLogger No Log4j 2 configuration file found 在将jmeter依赖项添加到我的pom.xml中时,获取log4j错误ERROR StatusLogger“未找到log4j2配置文件” - Gettting log4j error ERROR StatusLogger “No log4j2 configuration file found” while adding jmeter dependencies to my pom.xml Log4j2 配置 - 找不到 log4j2 配置文件 - Log4j2 configuration - No log4j2 configuration file found 使用java 9找不到log4j2配置文件 - log4j2 configuration file not found with java 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM