Reputation: 922
I have properties file
# Root logger option
log4j.rootLogger= INFO , stdout
# Redirect log messages to console
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
And java file
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class HelloWorld {
static final Logger log = LogManager.getLogger(HelloWorld.class);
public static void main(String[] args){
log.info("Test");
}
}
Everything is set but there is no output on the Console. That's log4j 2.0. What am i doing wrong?
Upvotes: 0
Views: 344
Reputation: 36754
You cannot use a log4j-1.2-style properties file to configure log4j2. Log4j2 needs an xml configuration file. It expects this file to be called "log4j2.xml" and placed in the classpath (although it is possible to specify a different location for this file). The manual has all the details. The manual also has many, many configuration examples to help you get started.
Upvotes: 2