diff --git a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java index 90ff80cbb3..711a319d22 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotConfig.java @@ -18,6 +18,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.RangedAttribute; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.Configuration; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -356,4 +359,27 @@ public class SpigotConfig SpigotConfig.attackDamage = SpigotConfig.getDouble( "settings.attribute.attackDamage.max", SpigotConfig.attackDamage ); ( (RangedAttribute) Attributes.ATTACK_DAMAGE.value() ).maxValue = SpigotConfig.attackDamage; } + + public static boolean debug; + private static void debug() + { + SpigotConfig.debug = SpigotConfig.getBoolean( "settings.debug", false ); + + if ( SpigotConfig.debug && !LogManager.getRootLogger().isTraceEnabled() ) + { + // Enable debug logging + LoggerContext ctx = (LoggerContext) LogManager.getContext( false ); + Configuration conf = ctx.getConfiguration(); + conf.getLoggerConfig( LogManager.ROOT_LOGGER_NAME ).setLevel( org.apache.logging.log4j.Level.ALL ); + ctx.updateLoggers( conf ); + } + + if ( LogManager.getRootLogger().isTraceEnabled() ) + { + Bukkit.getLogger().info( "Debug logging is enabled" ); + } else + { + Bukkit.getLogger().info( "Debug logging is disabled" ); + } + } } diff --git a/paper-server/src/main/resources/log4j2.xml b/paper-server/src/main/resources/log4j2.xml index edbd70b164..0ff3f750fb 100644 --- a/paper-server/src/main/resources/log4j2.xml +++ b/paper-server/src/main/resources/log4j2.xml @@ -24,10 +24,10 @@ - + - - + +