I'm using a JDK14Logger implementation to apache commons-loggings framework. The debug logs are not appearing, and they appear only when I set the root logger to FINE. My understanding is that log level set to specific handlers should override log level of root logger. However, that is not happening.
# The following creates the console handler
handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# Set the default logging level for the root logger
.level=FINE
# Set the default logging level
java.util.logging.ConsoleHandler.level=FINE
java.util.logging.FileHandler.level=FINEST
# log level for the "com.rst.example" package
# Set the default formatter
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
# Specify the location and name of the log file
java.util.logging.FileHandler.pattern=D:/test.log
test class:
public class Test {
private Log logger = LogFactory.getLog(Test.class.getName());
static {
System.getProperties().setProperty("java.util.logging.config.file","log-config.properties");
}
public static void main(String[] args) {
//-Djava.util.logging.config.file=src/main/resources/log-config.properties
Test test = new Test();
test.logger.info("info from main");
test.logger.error("error from main");
test.logger.fatal("fatal from main");
System.out.println("is dubug enabled? :" + test.logger.isDebugEnabled());
test.logger.debug("debug from main");
}
}