code: public void log(Level level, String message, Object... args) {
        if (logger.isLoggable(level)) {
           String errorMessage = "";
           Throwable thrown = null;
           Object[] params = null;
  
           if (args == null || args.length == 0) {
              errorMessage = message;
           } else if (args[0] instanceof Throwable) {
              thrown = (Throwable) args[0];
              if (args.length > 1) {
                 params = new Object[args.length - 1];
                 System.arraycopy(args, 1, params, 0, args.length - 1);
              }
           } else if (args[args.length - 1] instanceof Throwable) {
              params = new Object[args.length - 1];
              System.arraycopy(args, 0, params, 0, args.length - 1);
              thrown = (Throwable) args[args.length - 1];
           } else {
              params = new Object[args.length];
              System.arraycopy(args, 0, params, 0, args.length);
           }
  
           if (params != null) {
              errorMessage = MessageFormat.format(message, params);
           }
  
           LogRecord record = new LogRecord(level, errorMessage);
           record.setLoggerName(logger.getName());
           record.setThrown(thrown);
           record.setParameters(args);
           logger.log(record);
        }
     }
docs: Logs a message at a given level.
  
  @param level   The level to log the message at.
  @param message The message accompanying the log
  @param args    The arguments for the message.