Adding logging ability
Let's start with using the logging API in Java to log messages to the console. As an example, we want to be able to log some sample messages during the application start and completion.
What we'd typically do in Java 8 or earlier is just import the necessary logging classes and start using the logging APIs. That is, the Logger class from the java.util.logging package. However, as we've learned in the previous chapter, there's an additional step in Java 9. Using the logging APIs directly will result in a compilation error. That's because the logging APIs aren't available in the java.base module. We've seen that the best way to search for a module is using the --list-modules parameter to the java command. Let's run that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access