2018-08-06 07:46:43 +08:00
|
|
|
From 4aac22aa465248aaabd4292bf6804bf8c88d60fe Mon Sep 17 00:00:00 2001
|
2018-03-08 23:08:21 +08:00
|
|
|
From: Minecrell <minecrell@minecrell.net>
|
2017-09-18 18:07:47 +08:00
|
|
|
Date: Mon, 18 Sep 2017 12:00:03 +0200
|
|
|
|
Subject: [PATCH] Use Log4j IOStreams to redirect System.out/err to logger
|
|
|
|
|
|
|
|
Log4j2 provides an optimized implementation of PrintStream that
|
|
|
|
redirects its output to a logger. Use it instead of a custom
|
|
|
|
implementation for minor performance improvements and some fixes.
|
|
|
|
|
|
|
|
With the old implementation, each call to System.print()
|
|
|
|
results in a separate line, even though it should not result in
|
|
|
|
a line break. Log4j's implementation handles it correctly.
|
|
|
|
|
|
|
|
diff --git a/pom.xml b/pom.xml
|
2018-07-23 16:39:55 +08:00
|
|
|
index 47e307a246..a93ed45df9 100644
|
2017-09-18 18:07:47 +08:00
|
|
|
--- a/pom.xml
|
|
|
|
+++ b/pom.xml
|
2018-07-22 13:27:46 +08:00
|
|
|
@@ -89,6 +89,13 @@
|
2017-09-18 18:07:47 +08:00
|
|
|
<scope>runtime</scope>
|
|
|
|
</dependency>
|
|
|
|
|
|
|
|
+ <!-- Paper - Add additional Log4J dependencies -->
|
|
|
|
+ <dependency>
|
|
|
|
+ <groupId>org.apache.logging.log4j</groupId>
|
|
|
|
+ <artifactId>log4j-iostreams</artifactId>
|
|
|
|
+ <version>2.8.1</version>
|
|
|
|
+ </dependency>
|
|
|
|
+
|
|
|
|
<!-- testing -->
|
|
|
|
<dependency>
|
|
|
|
<groupId>junit</groupId>
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2018-07-23 16:39:55 +08:00
|
|
|
index af430b73f0..8c76300185 100644
|
2017-09-18 18:07:47 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2018-07-20 03:23:18 +08:00
|
|
|
@@ -131,8 +131,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
2017-09-18 18:07:47 +08:00
|
|
|
*/
|
|
|
|
// Paper end
|
|
|
|
|
|
|
|
- System.setOut(new PrintStream(new LoggerOutputStream(logger, Level.INFO), true));
|
|
|
|
- System.setErr(new PrintStream(new LoggerOutputStream(logger, Level.WARN), true));
|
|
|
|
+ // Paper start - Use Log4j IOStreams
|
|
|
|
+ System.setOut(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel(Level.INFO).buildPrintStream());
|
|
|
|
+ System.setErr(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel(Level.WARN).buildPrintStream());
|
|
|
|
+ // Paper end
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
thread.setDaemon(true);
|
|
|
|
--
|
2018-06-30 13:40:52 +08:00
|
|
|
2.18.0
|
2017-09-18 18:07:47 +08:00
|
|
|
|