2019-08-05 18:35:40 +02:00
|
|
|
From 293d21b77ff488266b8137593bf35c8cb805ba94 Mon Sep 17 00:00:00 2001
|
2018-03-08 16:08:21 +01:00
|
|
|
From: Minecrell <minecrell@minecrell.net>
|
2017-09-18 12:07:47 +02: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
|
2019-08-05 18:35:40 +02:00
|
|
|
index 58b14a740e..a70c0ec07a 100644
|
2017-09-18 12:07:47 +02:00
|
|
|
--- a/pom.xml
|
|
|
|
+++ b/pom.xml
|
2019-01-04 20:19:36 +01:00
|
|
|
@@ -63,6 +63,11 @@
|
2018-08-26 20:11:49 +02:00
|
|
|
<version>2.8.1</version>
|
2017-09-18 12:07:47 +02:00
|
|
|
<scope>runtime</scope>
|
|
|
|
</dependency>
|
|
|
|
+ <dependency>
|
|
|
|
+ <groupId>org.apache.logging.log4j</groupId>
|
|
|
|
+ <artifactId>log4j-iostreams</artifactId>
|
|
|
|
+ <version>2.8.1</version>
|
|
|
|
+ </dependency>
|
|
|
|
<dependency>
|
2018-08-26 20:11:49 +02:00
|
|
|
<groupId>org.ow2.asm</groupId>
|
|
|
|
<artifactId>asm</artifactId>
|
2017-09-18 12:07:47 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2019-08-05 18:35:40 +02:00
|
|
|
index 92d0aa6d66..c6eb88c34b 100644
|
2017-09-18 12:07:47 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2019-08-05 18:35:40 +02:00
|
|
|
@@ -147,8 +147,10 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
2017-09-18 12:07:47 +02: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);
|
|
|
|
--
|
2019-06-25 03:47:58 +02:00
|
|
|
2.22.0
|
2017-09-18 12:07:47 +02:00
|
|
|
|