Repository: quarkusio/quarkus
Issue: quarkus.application.name is not taken into account in stop message

If I add this to my `application.properties`:
```
quarkus.application.name=MyApp
```

Startup message is OK:
```
2019-10-10 14:39:15,327 INFO  [io.quarkus] (main) MyApp 1.0-SNAPSHOT (running on Quarkus 999-SNAPSHOT) started in 0.612s. Listening on: http://0.0.0.0:8080
2019-10-10 14:39:15,333 INFO  [io.quarkus] (main) Profile prod activated. 
2019-10-10 14:39:15,334 INFO  [io.quarkus] (main) Installed features: [agroal, cdi, narayana-jta, resteasy, security, security-jdbc]
```

But not the shutdown message:
```
^C2019-10-10 14:39:17,713 INFO  [io.quarkus] (main) Quarkus stopped in 0.029s
```

We should fix the shutdown message to be consistent.

Also we need to find a place to document this feature properly. But I couldn't find an obvious place.

Initial PR with the startup name: https://github.com/quarkusio/quarkus/pull/4302

Changed files:
core/runtime/src/main/java/io/quarkus/runtime/Timing.java
core/runtime/src/main/java/io/quarkus/runtime/Application.java
core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java
index 3c812874270..af9a314a80f 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/MainClassBuildStep.java
@@ -234,6 +234,11 @@ MainClassBuildItem build(List<StaticBytecodeRecorderBuildItem> staticInitTasks,
         mv.setModifiers(Modifier.PUBLIC | Modifier.STATIC);
 
         final ResultHandle appClassInstance = mv.newInstance(ofConstructor(appClassName));
+
+        // Set the application name
+        mv.invokeVirtualMethod(ofMethod(Application.class, "setName", void.class, String.class), appClassInstance,
+                mv.load(applicationInfo.getName()));
+
         // run the app
         mv.invokeVirtualMethod(ofMethod(Application.class, "run", void.class, String[].class), appClassInstance,
                 mv.getMethodParam(0));
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/Application.java b/core/runtime/src/main/java/io/quarkus/runtime/Application.java
index a0e8b2d721b..8cc773f7613 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/Application.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/Application.java
@@ -36,6 +36,7 @@ public abstract class Application {
     private final Lock stateLock = Locks.reentrantLock();
     private final Condition stateCond = stateLock.newCondition();
 
+    private String name;
     private int state = ST_INITIAL;
     private volatile boolean shutdownRequested;
     private static volatile Application currentApplication;
@@ -164,7 +165,7 @@ public final void stop() {
             stateLock.lock();
             try {
                 state = ST_STOPPED;
-                Timing.printStopTime();
+                Timing.printStopTime(name);
                 stateCond.signalAll();
             } finally {
                 stateLock.unlock();
@@ -178,6 +179,10 @@ public static Application currentApplication() {
 
     protected abstract void doStop();
 
+    public void setName(String name) {
+        this.name = name;
+    }
+
     /**
      * Run the application as if it were in a standalone JVM.
      */
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/Timing.java b/core/runtime/src/main/java/io/quarkus/runtime/Timing.java
index 60a993947bb..e834ae4ea71 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/Timing.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/Timing.java
@@ -58,8 +58,8 @@ public static void printStartupTime(String name, String version, String quarkusV
         final Logger logger = Logger.getLogger("io.quarkus");
         //Use a BigDecimal so we can render in seconds with 3 digits precision, as requested:
         final BigDecimal secondsRepresentation = convertToBigDecimalSeconds(bootTimeNanoSeconds);
-        String safeAppName = (name == null || name.isEmpty()) ? UNSET_VALUE : name;
-        String safeAppVersion = (version == null || version.isEmpty()) ? UNSET_VALUE : version;
+        String safeAppName = (name == null || name.trim().isEmpty()) ? UNSET_VALUE : name;
+        String safeAppVersion = (version == null || version.trim().isEmpty()) ? UNSET_VALUE : version;
         if (UNSET_VALUE.equals(safeAppName) || UNSET_VALUE.equals(safeAppVersion)) {
             logger.infof("Quarkus %s started in %ss. %s", quarkusVersion, secondsRepresentation, httpServerInfo);
         } else {
@@ -71,11 +71,13 @@ public static void printStartupTime(String name, String version, String quarkusV
         bootStartTime = -1;
     }
 
-    public static void printStopTime() {
+    public static void printStopTime(String name) {
         final long stopTimeNanoSeconds = System.nanoTime() - bootStopTime;
         final Logger logger = Logger.getLogger("io.quarkus");
         final BigDecimal secondsRepresentation = convertToBigDecimalSeconds(stopTimeNanoSeconds);
-        logger.infof("Quarkus stopped in %ss", secondsRepresentation);
+        logger.infof("%s stopped in %ss",
+                (UNSET_VALUE.equals(name) || name == null || name.trim().isEmpty()) ? "Quarkus" : name,
+                secondsRepresentation);
         bootStopTime = -1;
     }