From 4bc76b3012b5d8deeac4d007f30da44f649228ce Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 25 Jan 2021 01:50:56 -0500 Subject: [PATCH] Add JUL support to log4j Certain badly behaved plugins insist on logging with java.util.logging. Accommodate them. --- proxy/build.gradle | 1 + proxy/src/main/java/com/velocitypowered/proxy/Velocity.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/proxy/build.gradle b/proxy/build.gradle index 1ed87838e..25087f2e5 100644 --- a/proxy/build.gradle +++ b/proxy/build.gradle @@ -57,6 +57,7 @@ dependencies { implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" implementation "org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}" implementation "org.apache.logging.log4j:log4j-iostreams:${log4jVersion}" + implementation "org.apache.logging.log4j:log4j-jul:${log4jVersion}" implementation 'net.sf.jopt-simple:jopt-simple:5.0.4' // command-line options implementation 'net.minecrell:terminalconsoleappender:1.2.0' diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index 9185a4f40..619cb4a01 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -8,9 +8,12 @@ import org.apache.logging.log4j.Logger; public class Velocity { - private static final Logger logger = LogManager.getLogger(Velocity.class); + private static final Logger logger; static { + System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"); + logger = LogManager.getLogger(Velocity.class); + // We use BufferedImage for favicons, and on macOS this puts the Java application in the dock. // How inconvenient. Force AWT to work with its head chopped off. System.setProperty("java.awt.headless", "true");