I set logging level to CONFIG, but don't see messages written on CONFIG level. What I am missing?
Configuration:
Logger logger = java.util.logging.Logger.getLogger("xxx");
logger.setLevel(java.util.logging.Level.CONFIG);
Tests:
logger.log(java.util.logging.Level.SEVERE, "severe");
logger.log(java.util.logging.Level.WARNING, "warning");
logger.log(java.util.logging.Level.INFO, "info");
logger.log(java.util.logging.Level.CONFIG, "config");
logger.log(java.util.logging.Level.FINE, "fine");
logger.log(java.util.logging.Level.FINER, "finer");
logger.log(java.util.logging.Level.FINEST, "finest");
Output:
SEVERE: severe
WARNING: warning
INFO: info
I typically use logback to implement logging, which seems a tad better documented. So I would recommend switching to that.
But to answer your question, I think what is happening is that your
Logger
is configured correctly, but theHandler
it's sending its messages to isn't. The default configuration probably attaches a handler withINFO
level logging to the root logger.edit: I wrote a little test program to verify, you indeed need to set the level on the handler attached to the root logger. You can do so like this:
Gives as output:
This sets the level for all handlers attached to this. Obviously a better choice would be writing your own options file and explicitly configuring your loggers. A quick google turned up this article on the subject.
You could also try configuring with a properties file on your classpath that reads: