I have a pretty simple logging.properties
config:
handlers = java.util.logging.ConsoleHandler
.level = INFO
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%4$s] %5$s %n
If .level
is set to INFO I got all my INFO and higher messages as expected. But if I set the .level
to FINE, FINER, FINEST or ALL. None of messages from my code is displayed (neither WARNING or SEVERE). All "internal" FINE, FINER etc. messages are displayed properly, but not those from my code.
I tried to add a specific level for my packages:
org.example.mypackage.level = INFO
but it has no effect to the issue. Once the global .level
is set to FINE or lower or ALL, none of message produced by my code are displayed regardless their level.
What is wrong here? Is there any such a rule (I haven't find anything on the web).
I'm running my tests using maven:
mvn test -Djava.util.logging.config.file=/path/to/my/logging.properties
And my code that produces log messages looks like this:
public class MyClass {
private static final logger = Logger.getLogger(MyClass.class.getName());
public void someMethod() {
logger.log(Level.WARNING, "Warning message");
}
}
UPDATE:
This must be related to maven. Once the app is compiled and run on its own (pure java SE - no app server, no containers) the issue is no more a problem. Only when run using mvn ...
the logging behaves as described above.