[英]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#AutomaticConfiguration将log4j2.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'并从指定的文件加载配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.