From ce34fd1ade2a0388034b2f93b5c2615c1ee61e30 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Thu, 21 Sep 2017 16:34:36 +0200 Subject: [PATCH] Allow plugins to use SLF4J for logging SLF4J is a commonly used abstraction for various logging frameworks such as java.util.logging (JUL) or Log4j. Currently, plugins are required to do all their logging using the provided JUL logger. This is annoying for plugins that target multiple platforms or when using libraries that log messages using SLF4J. Expose SLF4J as optional logging API for plugins, so they can use it without having to shade it in the plugin and going through several layers of logging abstraction. --- ...low-plugins-to-use-SLF4J-for-logging.patch | 54 +++++++++++++++++++ ...-Include-Log4J2-SLF4J-implementation.patch | 26 +++++++++ 2 files changed, 80 insertions(+) create mode 100644 Spigot-API-Patches/0068-Allow-plugins-to-use-SLF4J-for-logging.patch create mode 100644 Spigot-Server-Patches/0240-Include-Log4J2-SLF4J-implementation.patch diff --git a/Spigot-API-Patches/0068-Allow-plugins-to-use-SLF4J-for-logging.patch b/Spigot-API-Patches/0068-Allow-plugins-to-use-SLF4J-for-logging.patch new file mode 100644 index 0000000000..b1300dd0c8 --- /dev/null +++ b/Spigot-API-Patches/0068-Allow-plugins-to-use-SLF4J-for-logging.patch @@ -0,0 +1,54 @@ +From fd9c40f3f333eab91c410c02c20b7b9f7c64ebf2 Mon Sep 17 00:00:00 2001 +From: Minecrell +Date: Thu, 21 Sep 2017 16:33:12 +0200 +Subject: [PATCH] Allow plugins to use SLF4J for logging + +SLF4J is a commonly used abstraction for various logging frameworks +such as java.util.logging (JUL) or Log4j. Currently, plugins are +required to do all their logging using the provided JUL logger. +This is annoying for plugins that target multiple platforms or when +using libraries that log messages using SLF4J. + +Expose SLF4J as optional logging API for plugins, so they can use +it without having to shade it in the plugin and going through +several layers of logging abstraction. + +diff --git a/pom.xml b/pom.xml +index ad385f45..b83c6eb1 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -122,6 +122,14 @@ + compile + + ++ ++ ++ org.slf4j ++ slf4j-api ++ 1.7.25 ++ compile ++ ++ + + + junit +diff --git a/src/main/java/org/bukkit/plugin/Plugin.java b/src/main/java/org/bukkit/plugin/Plugin.java +index c4e22c62..02670254 100644 +--- a/src/main/java/org/bukkit/plugin/Plugin.java ++++ b/src/main/java/org/bukkit/plugin/Plugin.java +@@ -157,6 +157,12 @@ public interface Plugin extends TabExecutor { + */ + public Logger getLogger(); + ++ // Paper start - Add SLF4J logger ++ default org.slf4j.Logger getSLF4JLogger() { ++ return org.slf4j.LoggerFactory.getLogger(getLogger().getName()); ++ } ++ // Paper end ++ + /** + * Returns the name of the plugin. + *

+-- +2.14.1 + diff --git a/Spigot-Server-Patches/0240-Include-Log4J2-SLF4J-implementation.patch b/Spigot-Server-Patches/0240-Include-Log4J2-SLF4J-implementation.patch new file mode 100644 index 0000000000..2c01e2e79d --- /dev/null +++ b/Spigot-Server-Patches/0240-Include-Log4J2-SLF4J-implementation.patch @@ -0,0 +1,26 @@ +From e4b022439652ed4b044c10cadb7525671bcd54f3 Mon Sep 17 00:00:00 2001 +From: Minecrell +Date: Thu, 21 Sep 2017 16:33:35 +0200 +Subject: [PATCH] Include Log4J2 SLF4J implementation + + +diff --git a/pom.xml b/pom.xml +index fa726851b..647b2c619 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -98,6 +98,12 @@ + + + ++ ++ org.apache.logging.log4j ++ log4j-slf4j-impl ++ 2.8.1 ++ runtime ++ + + org.apache.logging.log4j + log4j-iostreams +-- +2.14.1 +