Maven - ERROR StatusLogger log4j2 configuration file not found

When running mvn verify I get the message below:

enter image description here

I already put log4j2.xml under src/test/resources (but not in src/main/resources , because I don't want it to go with the real application), as suggested here to no avail.

enter image description here

An HTML report is generated, a log file is written, and the assembly is successful, as shown above. I'm not sure where the error comes from.

log4j2.xml

 <?xml version="1.0" encoding="UTF-8"?> <Configuration status="WARN"> <Properties> <Property name="logPath">target/cucumber-logs</Property> </Properties> <Appenders> <RollingFile name="fileLogger" fileName="${logPath}/cucumber-log.log" filePattern="${logPath}/cucumber-log_%d{yyyy-MM-dd}.log"> <PatternLayout> <pattern>[%-5level] %d{HH:mm:ss.SSS} %logger{36}.%M() - %msg%n </pattern> </PatternLayout> <Policies> <OnStartupTriggeringPolicy /> <TimeBasedTriggeringPolicy interval="1" modulate="true" /> </Policies> </RollingFile> <Console name="console" target="SYSTEM_OUT"> <PatternLayout> <pattern>[%-5level] %d{HH:mm:ss.SSS} %logger{36}.%M() - %msg%n </pattern> </PatternLayout> </Console> </Appenders> <Loggers> <Root level="TRACE" additivity="false"> <AppenderRef ref="console" /> <AppenderRef ref="fileLogger" /> </Root> </Loggers> </Configuration> 

pom.xml:

 <dependencies> <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>${selenium.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.paulhammant/ngwebdriver --> <dependency> <groupId>com.paulhammant</groupId> <artifactId>ngwebdriver</artifactId> <version>${ngwebdriver.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-testng</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-picocontainer</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.10.0</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20.1</version> <configuration> <includes> <include>**/*Runner.java</include> </includes> <testFailureIgnore>true</testFailureIgnore> <reportsDirectory>./target/test-output/${timestamp}</reportsDirectory> </configuration> </plugin> <plugin> <groupId>net.masterthought</groupId> <artifactId>maven-cucumber-reporting</artifactId> <version>3.15.0</version> <executions> <execution> <id>execution</id> <phase>verify</phase> <goals> <goal>generate</goal> </goals> <configuration> <projectName>Simply Do - Balance Projector</projectName> <outputDirectory>${project.build.directory}</outputDirectory> <jsonFiles> <param>${project.build.directory}/cucumber-generated-reports/cucumber-report.json</param> </jsonFiles> <parallelTesting>false</parallelTesting> </configuration> </execution> </executions> </plugin> </plugins> </build> 
+5
source share
5 answers

You are using the latest version of Cucumber 3.15.0 (as of this writing). Your problem has been resolved as issue # 675 . There was a commit from the pull request to fix this problem, but you probably need to wait until the next version is released to take advantage of it, or create a local version of the snapshot and see if it fixes this problem.

+1
source

According to http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration adding log4j2.xml to the classpath should help.

If the JSON file cannot be found, the XML ConfigurationFactory will try to find log4j2.xml in the classpath.

So, if the problem with the ERROR message is still not related to your sources. This seems like a problem in the maven-cucumber-reporting plugin. As described here http://maven.apache.org/guides/mini/guide-maven-classloading.html

Please note that the plugin class loader does not contain dependencies of the current project and its assembly.

If the maven plugin cannot find the log4j configuration in its own classpath (which does not include your sources / resources), you will see error messages. So yes, the only solution is waiting for the release with the fix https://github.com/damianszczepanik/cucumber-reporting/issues/675

+1
source

Run -> Run Configurations -> Classpath -> User entries -> Advanced Optionses -> Add Folders -> Then add your folder, in your case src / test / resources -> apply

Now it should work: D

+1
source

You get this error because cucumber or its dependencies use log4j for logging, and because there is no log4j configuration file, therefore log4j prints such a message.

If there is no log4j configuration file, log4j uses a configuration similar to the one below -

 <?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 the above configuration to /src/main/resources/log4j2.xml will have the same result as without the log4j2.xml file.

Another way to try is to pass the log4j2.xml file to maven directly, without putting it in the project class path. Something like below -

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

according to their documentation, you can use "joranConfigurator" and load the configuration from the specified file

documentation link

+1
source

Source: https://habr.com/ru/post/1275943/


All Articles