This article contains Java 9 Logger framework configuration with detail explanation and examples. Java 9 Logger new API with detail explanation.


Java 9 provide inbuilt logger framework in side package java.util.logging. Reason behind create Logger support in java 9 as under:

  • Defined and used in the java.base module, hence it cannot depend upon the java.util.logging API.
  • Be easily adoptable by applications which use external logging framework, such as SLF4J or Log4J.
  • Reduce dependencies on the java.logging module in order to simplify the JDK module graph.
  • Deals with bootstrap issues, so that platform classes can log messages before the log consumer is initialized.
  • By default, log messages via the java.util.logging API when the java.logging module is present

Let’s see some configuration in java 9 for Logger:

  1. The default configuration is typically loaded from the properties file [JAVA_HOME]/conf/ in the Java installation directory
  2. If the “java.util.logging.config.file” system property is set, then the property value specifies the properties file to be read as the new configuration. Otherwise, the LogManager default configuration is used.
  3. LOG File will be created at default user home location.
  4. If you want to change log file location then change path in below location in file
  5. Java Default Location:
    java.util.logging.FileHandler.pattern = %h/java%u.log
    Modify To
    java.util.logging.FileHandler.pattern = [YOUR_LOCATION]/java%u.log
  6.  NOTE: By default java only configure a ConsoleHandler, which will only show messages at the INFO and above levels. If you want to write LOG on file then need to enable java.util.logging.FileHandler.
  7. Go to file and remove comment from
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler

8. java 9 Logger types : SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST (Read for more information)



    module firstmodule {
        requires java.logging;

    import java.util.logging.Logger;
    public class Main {
        public static void main(String[] args) {
            Logger logger = Logger.getLogger("FirstModule");
  "JavaDeveloperZone first log.");
  "JavaDeveloperZone second log.");

    If you are using module based development than do not forgot to add dependency of Logging module:


    Mar 26, 2017 11:36:57 PM main
    INFO: JavaDeveloperZone first log.
    Mar 26, 2017 11:36:58 PM main
    INFO: JavaDeveloperZone second log.
    Disconnected from the target VM, address: '', transport: 'socket'
    Process finished with exit code 0


    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE log SYSTEM "logger.dtd">
      <message>JavaDeveloperZone first log.</message>
      <message>JavaDeveloperZone second log.</message>


Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *