Make debug logging togglable.

By: Minecrell <dev@minecrell.net>
This commit is contained in:
CraftBukkit/Spigot 2014-08-17 12:42:53 +02:00
parent f026f7905e
commit c34736a0d2
2 changed files with 29 additions and 3 deletions

View file

@ -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" );
}
}
}

View file

@ -24,10 +24,10 @@
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
</filters>
<AppenderRef ref="SysOut"/>
<AppenderRef ref="SysOut" level="info"/>
<AppenderRef ref="File"/>
<AppenderRef ref="ServerGuiConsole"/>
<AppenderRef ref="TerminalConsole"/>
<AppenderRef ref="ServerGuiConsole" level="info"/>
<AppenderRef ref="TerminalConsole" level="info"/>
</Root>
</Loggers>
</Configuration>