No log4j2 configuration file found


(Daniel Florian) #1

Hello,
I tried to import a Maven Project on Eclipse, but there's problem. Eclipse sent me this :

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.

But, I checked and I have a log4j2.properties in the path src/main/resources :

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
rootLogger.level = info
rootLogger.appenderRef.console.ref = console 

This is my 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>projet</groupId>
  <artifactId>google</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>google</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>org.elasticsearch.client</groupId>
		<artifactId>transport</artifactId>
		<version>5.4.0</version>
	</dependency>
	
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.8.2</version>
</dependency>

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.8.2</version>
</dependency>

  </dependencies>
  
    <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>org.ccm.maven.App</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

That's my app.java that I tried to compile :

package projet;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;



/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
    	// on startup
    	
    	
        try{
    		TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
    		        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getLocalHost(), 9300));
    		}
    		catch(UnknownHostException u){
    		  System.out.println("exception:" + u.getMessage());
    		  u.printStackTrace();
    		}
    	
		}
}

It's weird because I always think, when I modify my files, to compile with "mvn compile" or refresh on Eclipse.

Thank you for your answers. :wink:


(David Pilato) #2

This is happening when you launch from eclipse or from the command line?


(Daniel Florian) #3

This is when I launch from eclipse :wink:


(David Pilato) #4

My bet is that something is not well configured within eclipse.
But as I'm not using eclipse for more than 4 years now I doubt I can help more.

At least check that you have all files in the target/classes dir.


(Daniel Florian) #5

I will check that. But have you got a simple example of Java classes in ElasticSearch ?
An example which create an index, add a Document and search this Document.

Thank you for your help !


(David Pilato) #6

(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.