Repository: quarkusio/quarkus
Issue: Named handler log files get logs duplicated when hot reload is performed

**Describe the bug**
In properties file I have configured 2 different named handlers, for very specific logging categories. 
In dev mode the log in these categories are working fine and directed toward the right file handler.
When an hot-reload is performed I see the log lines duplicated, and each time a new hot-reload is performed there is one more copy of the log lines pushed to the files. 
This might be related to the named log handler being registered multiple times on hot reload, I'm guessing, because console log and the general `quarkus.log.file.path` do not get duplicates traces after several hot reloads.

**Expected behavior**
Hot reload should reset logging configuration, and not duplicate log lines in named handler files

**Actual behavior**
After hot reload duplicate log lines are added to named handler log files, and the duplication factor is the number of live reloads performed.

**To Reproduce**
Steps to reproduce the behavior:
1. Configure named log handler
2. Append to the matching log topic/categories
3. See log lines appears one at a time
4. Perform hot reload, changing a blank line in source or something meaningless
5. See log lines appears duplicate
6. Perform another hot reload
7. See log lines appear 3 times each 

**Configuration**
```properties
# Add your application.properties here, if applicable.

#Logging
quarkus.log.level=INFO
quarkus.log.category."com.darva.urlshortener".level=DEBUG

# Configure a named handler that logs to Activite file
quarkus.log.handler.file."ACTIVITE".enable=true
quarkus.log.handler.file."ACTIVITE".path=../logs/activite.log
quarkus.log.handler.file."ACTIVITE".format=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX};%X{raisonsociale};%X{userroles};%X{sessionId};%X{posteId};%X{userId};%X{versionApp};%X{service};SERVICE-NAME;%X{numclient};%X{transactionId};%X{versionConfApp};%X{versionConfTech};%X{codePro};%X{codeAbo};%m%n
quarkus.log.category."com.company.log.ActivityTracer".level=INFO
quarkus.log.category."com.company.log.ActivityTracer".handlers=ACTIVITE

# Configure a named handler that logs to Exploitation file
quarkus.log.handler.file."EXPLOITATION".enable=true
quarkus.log.handler.file."EXPLOITATION".path=../logs/exploitation.log
quarkus.log.handler.file."EXPLOITATION".format=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX};%X{raisonsociale};%X{userroles};%X{sessionId};%X{posteId};%X{userId};%X{versionApp};%X{service};SERVICE-NAME;%X{numclient};%X{transactionId};%X{versionConfApp};%X{versionConfTech};%X{codePro};%X{codeAbo};%p;%C;%m;%M%n
quarkus.log.category."com.company.log.ExploitationTracer".level=ERROR
quarkus.log.category."com.company.log.ExploitationTracer".handlers=EXPLOITATION

# General log goes to Application file
quarkus.log.file.enable=true
quarkus.log.file.path=../logs/application.log
quarkus.log.file.format=%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX};%X{raisonsociale};%X{userroles};%X{sessionId};%X{posteId};%X{userId};%X{versionApp};%X{service};SERVICE-NAME;%X{numclient};%X{transactionId};%X{versionConfApp};%X{versionConfTech};%X{codePro};%X{codeAbo};%p;%C;%m;%M%n
quarkus.log.file.level=DEBUG
quarkus.log.min-level=DEBUG
```

**Environment (please complete the following information):**
 - Output of `uname -a` or `ver`: Darwin ***********.local 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
 - Output of `java -version`: java version "11.0.7" 2020-04-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS, mixed mode)
 - GraalVM version (if different from Java): 
 - Quarkus version or git rev: 1.5.2.Final
 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

**Additional context**
This all happened in dev mode, running the application using either `mvn quarkus:dev` or `./mvnw quarkus:dev`. Not very critical to me either, as hot reload is only useful for dev environment.


Changed files:
independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java
core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java

diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java
index 3bd50a147ad..9715b77d878 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java
@@ -289,14 +289,27 @@ private static void addToNamedHandlers(Map<String, Handler> namedHandlers, Handl
                     handlerName));
         }
         namedHandlers.put(handlerName, handler);
+        InitialConfigurator.DELAYED_HANDLER.addLoggingCloseTask(new Runnable() {
+            @Override
+            public void run() {
+                handler.close();
+            }
+        });
     }
 
     private static void addNamedHandlersToCategory(CategoryConfig categoryConfig, Map<String, Handler> namedHandlers,
             Logger categoryLogger,
             ErrorManager errorManager) {
         for (String categoryNamedHandler : categoryConfig.handlers.get()) {
-            if (namedHandlers.get(categoryNamedHandler) != null) {
-                categoryLogger.addHandler(namedHandlers.get(categoryNamedHandler));
+            Handler handler = namedHandlers.get(categoryNamedHandler);
+            if (handler != null) {
+                categoryLogger.addHandler(handler);
+                InitialConfigurator.DELAYED_HANDLER.addLoggingCloseTask(new Runnable() {
+                    @Override
+                    public void run() {
+                        categoryLogger.removeHandler(handler);
+                    }
+                });
             } else {
                 errorManager.error(String.format("Handler with name '%s' is linked to a category but not configured.",
                         categoryNamedHandler), null, ErrorManager.GENERIC_FAILURE);
diff --git a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java
index ae28d6fc633..b39f29a5d57 100644
--- a/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java
+++ b/independent-projects/bootstrap/runner/src/main/java/io/quarkus/bootstrap/logging/QuarkusDelayedHandler.java
@@ -17,7 +17,9 @@
 package io.quarkus.bootstrap.logging;
 
 import java.util.ArrayDeque;
+import java.util.ArrayList;
 import java.util.Deque;
+import java.util.List;
 import java.util.logging.ErrorManager;
 import java.util.logging.Formatter;
 import java.util.logging.Handler;
@@ -36,6 +38,7 @@
 public class QuarkusDelayedHandler extends ExtHandler {
 
     private final Deque<ExtLogRecord> logRecords = new ArrayDeque<>();
+    private final List<Runnable> logCloseTasks = new ArrayList<>();
 
     private final int queueLimit;
     private volatile boolean buildTimeLoggingActivated = false;
@@ -135,6 +138,10 @@ public Handler[] setHandlers(final Handler[] newHandlers) throws SecurityExcepti
         return result;
     }
 
+    public void addLoggingCloseTask(Runnable runnable) {
+        logCloseTasks.add(runnable);
+    }
+
     public synchronized Handler[] setBuildTimeHandlers(final Handler[] newHandlers) throws SecurityException {
         final Handler[] result = super.setHandlers(newHandlers);
         buildTimeLoggingActivated = true;
@@ -177,6 +184,9 @@ public void removeHandler(final Handler handler) throws SecurityException {
     @Override
     public Handler[] clearHandlers() throws SecurityException {
         activated = false;
+        for (Runnable i : logCloseTasks) {
+            i.run();
+        }
         return super.clearHandlers();
     }