Class Jdk14Logger

  • All Implemented Interfaces:
    Logger

    public class Jdk14Logger
    extends Object
    implements Logger
    Jdk14Logger is controller by java.util.logging.LogManager, which uses java.util.logging.config.file system property to load config file. If this property is not specified, then the config file is retrieved from its default location at $JAVA_HOME/jre/lib/logging.properties. The default config file uses INFO level for all loggers and having that exceptions are printed using WARN level by ConsoleHandler, you'll see log records without custom config file. Here is example using custom config file:
     # example of custom logging.properties for com.nuodb.jdbc.logger.Jdk14Logger
     handlers=java.util.logging.ConsoleHandler
    
     # Default global logging level
     # Loggers and Handlers may override this level
     .level=INFO
    
     # Loggers, these are usually attached to packages
     # Here, the level for each package is specified.
     package.name1.level=ALL
     package.name2.level=SEVERE
    
     # Handlers
     # Override global logging level
     java.util.logging.ConsoleHandler.level=FINE
     java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
     
    com.nuodb.jdbc.logger.Jdk14Logger will be managed by custom logging.properties:
     java -Djava.util.logging.config.file=logging.properties Jdk14LoggerTest
    
     public class Jdk14LoggerTest {
         public static void main(String[] args) throws java.sql.SQLException {
              Connection connection = null;
              try {
                  String url = "jdbc:com.nuodb://localhost/test?user=dba&password=dba";
                  // the connection will use com.nuodb.jdbc.logger.Jdk14Logger
                  Properties properties = new Properties();
                  properties.put("jdk14Logger", "true");
                  connection = DriverManager.getConnection(url, properties);
                  // this is parent java.util.logging.Logger for all child loggers
                  Logger parentLogger = DriverManager.getDriver(url).getParentLogger();
              } finally {
                  if (connection != null) {
                      connection.close();
                  }
              }
         }
     }
     
    Author:
    Sergey Bushik