What is the significance of log4j.rootLogger
property in log4j.properties
file? What happens if I don\'t use this property?
Example
To answer
What happens if I don't use this property?
If you don't set the rootLogger to a level and an appender, you will get a warning.
For example, if you omit or comment out the line log4j.rootLogger=DEBUG, stdout
, i.e. say your log4j.properties file contains only the rootlogger and no additional loggers, here the root logger being commented out:
#log4j.rootLogger=DEBUG, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
You will get something like the following output:
log4j:WARN No appenders could be found for logger (log4jtests.Log4jHelloWorld).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.