I am in the process of migrating from log4j 1.2 to log4j 2.
I have my whole configuration into a log4j2.properties file.
I noticed that I got a new error message in my logs while starting my tomcat :
log4j:WARN No appenders could be found for logger (org.springframework.web.filter.CharacterEncodingFilter). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
I have verified with my previous logs, and I did not have this warning previously.
Here is my previous configuration (in the log4j.properties file):
log4j.rootLogger=INFO, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{dd-MM HH:mm:ss} %p %t %c - %m%n
log4j.logger.com.example=DEBUG
log4j.logger.org.springframework=INFO
Here is the new one (in log4j2.properties) :
appender.console.type = Console
appender.console.name = ConsoleAppender
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d %p %t %c - %m%n
loggers = log1, log2
logger.log1.name = org.springframework
logger.log1.level = INFO
logger.log1.appenderRef = ConsoleAppender
logger.log2.name = com.example
logger.log2.level = DEBUG
logger.log2.appenderRef = ConsoleAppender
rootLogger.level = ERROR
rootLogger.appenderRef.stdout.ref = ConsoleAppender
So, what I've understand so far is :
- I create one appender, named ConsoleAppender, of type Console
- I create two loggers that goes each onto ConsoleAppender, one on org.springframework (level INFO) and the other on com.example (level INFO)
I use this page to try to understand how to do the migration.
Do you see any explanation about why I should have this particular message ?