From f0ea638fa1480875155dbd27c3b61246e95aa4e6 Mon Sep 17 00:00:00 2001 From: kyngs <38181667+kyngs@users.noreply.github.com> Date: Mon, 14 Mar 2022 04:59:50 +0100 Subject: [PATCH] Disable Log4J's built-in shutdown hook, because it broke logging in the shutdown sequence when exiting by interrupting the process. This was caused by the Log4J's hook running before ours. (#637) --- .../main/java/com/velocitypowered/proxy/VelocityServer.java | 3 +++ proxy/src/main/resources/log4j2.xml | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java index 2e5ffa9dd..4caa2b788 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/VelocityServer.java @@ -502,6 +502,9 @@ public class VelocityServer implements ProxyServer, ForwardingAudience { Thread.currentThread().interrupt(); } + // Since we manually removed the shutdown hook, we need to handle the shutdown ourselves. + LogManager.shutdown(); + shutdown = true; if (explicitExit) { diff --git a/proxy/src/main/resources/log4j2.xml b/proxy/src/main/resources/log4j2.xml index ddbac0715..5b3e217a9 100644 --- a/proxy/src/main/resources/log4j2.xml +++ b/proxy/src/main/resources/log4j2.xml @@ -16,7 +16,8 @@ along with this program. If not, see . --> - + +