Reputation: 1140
I'm using Itellij with maven and lately I started trying working with Log4j.
I imported the next dependencies on my pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
and also set a log4j.properties file under my resources directory like this:
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
Whenever I try to use log4j on my code I'm getting the next error:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
I have looked through the internet, and all places state that the properties/xml file should be set properly at my classpath (which I did).
What am I missing here?
Upvotes: 1
Views: 93
Reputation: 9151
As Pascal says, the name of your configuration file is incorrect. In addition, you are using the log4j 1.x property file syntax. The syntax is different in Log4j 2. Please review http://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax which describes how to configure with XML, JSON and properties.
Upvotes: 1
Reputation: 259
Your pom.xml uses Log4j2. Its configuration files must be named log4j2.properties (or log4j2.xml).
Upvotes: 0