There is a maven project, it has two cleint, server modules. In the main pom.xml connected all the necessary dependencies. Each module contains a log42.xml file in which saving logs to a specific file is written in the path. When compiling a project, an error is thrown.

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

Main pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>by.runets</groupId> <artifactId>accountingSystem</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <name>accountingSystem</name> <url>http://maven.apache.org</url> <modules> <module>server</module> <module>client</module> </modules> <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.7</version> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.10</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.7</version> </dependency> <dependency> <groupId>com.zenjava</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>8.8.0</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>6.0.6</version> </dependency> </dependencies> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project> 

pom.xml client module

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>accountingSystem</artifactId> <groupId>by.runets</groupId> <version>1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>client</artifactId> <packaging>jar</packaging> <name>client</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>com.jfoenix</groupId> <artifactId>jfoenix</artifactId> <version>1.4.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <addMavenDescriptor>false</addMavenDescriptor> <compress>true</compress> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>libs/</classpathPrefix> <mainClass>a1s.client.App</mainClass> </manifest> </archive> </configuration> <version>2.4</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/libs</outputDirectory> </configuration> </execution> </executions> <version>2.5.1</version> </plugin> <plugin> <groupId>com.zenjava</groupId> <artifactId>javafx-maven-plugin</artifactId> <version>8.8.0</version> <configuration> <mainClass>by.runets.accountingsystem.main.MainApp</mainClass> </configuration> </plugin> </plugins> </build> </project> 

log42.xml

 <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Appenders> <File name="fileLog" fileName="log/logs.txt" append="true"> <BurstFilter level = "debug"/> <PatternLayout pattern="%d{HH:mm:ss} %-5p [%t] %c{2} - %m%n"/> </File> <Console name="consoleLog" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss} %-5p [%t] %C{2} (%F:%L) - %m%n"/> </Console> </Appenders> <Loggers> <Root level="debug"> <AppenderRef ref="consoleLog"/> <AppenderRef ref="fileLog"/> </Root> </Loggers> </Configuration> 
  • Show how you run jar'nik. -Dlog4j.configurationFile exactly the correct path indicates? - Suvitruf
  • @Suvitruf launch from ide - OfficialDev
  • Show the structure of the project. Where do you log42.xml lies? - Suvitruf
  • By the way, the file should be called log4j2.xml , not log42.xml . - Suvitruf
  • one
    A small note: <scope> compile </ scope> It is not necessary to write, because the default scope for dependencies is compile. - aleshka-batman

1 answer 1

log4j2.xml should be in src / main / resources .