Waterfall/BungeeCord-Patches/0043-Add-Log4j-configuration-that-replicates-the-old-Bung.patch
Minecrell f8cc726520 Set up Log4j 2 async loggers using system property
From the Log4j 2 documentation:

  When AsyncLoggerContextSelector is used to make all loggers asynchronous,
  make sure to use normal <root> and <logger> elements in the configuration.
  The AsyncLoggerContextSelector will ensure that all loggers are
  asynchronous, using a mechanism that is different from what happens when
  you configure <asyncRoot> or <asyncLogger>. The latter elements are
  intended for mixing async with sync loggers.

https://logging.apache.org/log4j/2.x/manual/async.html

Since we are not using mixed sync/async loggers, we should use the
system property to enable the async loggers.
2018-07-18 16:12:17 +01:00

52 lines
2.2 KiB
Diff

From ca65f501ae9962731c785cba7d7b3b1357f8df4e Mon Sep 17 00:00:00 2001
From: Minecrell <minecrell@minecrell.net>
Date: Sun, 24 Sep 2017 12:06:49 +0200
Subject: [PATCH] Add Log4j configuration that replicates the old BungeeCord
setup
Can be enabled using -Dlog4j.configurationFile=log4j2-bungee.xml.
diff --git a/log4j/src/main/resources/log4j2-bungee.xml b/log4j/src/main/resources/log4j2-bungee.xml
new file mode 100644
index 00000000..6e9c09c5
--- /dev/null
+++ b/log4j/src/main/resources/log4j2-bungee.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Log4j configuration that replicates the old BungeeCord logging setup -->
+<Configuration status="warn">
+ <Appenders>
+ <TerminalConsole name="TerminalConsole">
+ <PatternLayout>
+ <LoggerNamePatternSelector defaultPattern="%highlightError{%d{HH:mm:ss} [%level] [%logger] %minecraftFormatting{%msg}%n%ex}">
+ <!-- Log root and BungeeCord loggers without prefix -->
+ <PatternMatch key=",BungeeCord" pattern="%highlightError{%d{HH:mm:ss} [%level] %minecraftFormatting{%msg}%n%ex}" />
+ </LoggerNamePatternSelector>
+ </PatternLayout>
+ </TerminalConsole>
+ <RollingRandomAccessFile name="File" fileName="proxy.log.0" filePattern="proxy.log.%i" immediateFlush="false">
+ <PatternLayout>
+ <LoggerNamePatternSelector defaultPattern="%d{HH:mm:ss} [%level] [%logger] %minecraftFormatting{%msg}{strip}%n%ex">
+ <!-- Log root and BungeeCord loggers without prefix -->
+ <PatternMatch key=",BungeeCord" pattern="%d{HH:mm:ss} [%level] %minecraftFormatting{%msg}{strip}%n%ex" />
+ </LoggerNamePatternSelector>
+ </PatternLayout>
+ <Policies>
+ <OnStartupTriggeringPolicy />
+ <SizeBasedTriggeringPolicy size="8 MB" />
+ </Policies>
+ <DefaultRolloverStrategy fileIndex="min" max="8" />
+ </RollingRandomAccessFile>
+ </Appenders>
+
+ <Loggers>
+ <Root level="info">
+ <AppenderRef ref="TerminalConsole" />
+ <AppenderRef ref="File" />
+ </Root>
+ </Loggers>
+</Configuration>
--
2.18.0