I'm trying to setup a logger for my application I want to do that through logger.properties file specified for this project. I use a following code to set it up:
InputStream loggerProps = getClass().getResourceAsStream("/logger.properties");
LogManager.getLogManager().readConfiguration(loggerProps);
That file contain following text:
handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level = ALL
java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%4$-7s] %5$s %n
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
#part about FileHandler omitted
And the problem is the given format isn't applied to the logged messages at all. However, it only doesn't in Java 8 (maybe earlier versions as well, haven't checked it). When I try the above in Java 9 or 10 it works just fine.
From what I can tell the file is loaded properly. Getting rid of ConsoleHandler in the first line causes logs not to be displayed in the console. Changing handler's level works as expected as well.
If I call the following method after setting properties:
LogManager.getLogManager().getProperty("java.util.logging.SimpleFormatter.format")
it returns the correct format string.
I've tried placing the format string inside both double quotes and single quotes, neither does work.
What am I doing wrong? Where is the problem? Isn't the format supported in Java version lower than 9?