Adding custom appender to Bukkit on runtime

Discussion in 'Plugin Development' started by Chloe-chan, Feb 2, 2017.

Thread Status:
Not open for further replies.
  1. Offline


    Hi all,

    I wanted to add a custom appender to Bukkit's internal Log4J2 on runtime to capture the LogEvents. However, when I include the latest Log4J2 (2.8) and shaded it into my plugin's JAR, I received the following error.
    ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
    This is the configuration in the POM I've used to shade the JAR.
    The code I've tried to use is as shown here.
            PatternLayout layout = PatternLayout.createDefaultLayout();
            Appender appender = new AbstractAppender("CustomAppender", null, layout)
                public void append(LogEvent logEvent)
            LoggerContext context = (LoggerContext) LogManager.getContext(false);
            Configuration config = context.getConfiguration();
    This has also caused additional errors to be logged in the console.
    [16:58:10 ERROR]: Error occurred while enabling TestLogging v1.0 (Is it up to date?)
    java.lang.ClassCastException: cannot be cast to
            at ~[?:?]
            at ~[spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at [spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugin( [spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at org.bukkit.craftbukkit.v1_10_R1.CraftServer.enablePlugins( [spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at net.minecraft.server.v1_10_R1.DedicatedServer.init( [spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at [spigot-1.10.2.jar:git-Spigot-1e4dd71-4507d99]
            at Source) [?:1.8.0_121]
    Any help to add custom appenders would be greatly appreciated.
Thread Status:
Not open for further replies.

Share This Page