mercredi 2 septembre 2020

Can I fix error with loading class in application?

I'm trying to add filter to org.apache.logging.log4j.Logger, but the event class, where I want to edit the message, show me error, it didn't load, but after this error the event class works perfect. It's just about a loading.

Event catching class:

private final Logger logger = LogManager.getLogger();

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onLogging(LoggingEvent event) {

    String message = event.getMessage();

    //INFO - IF MESSAGE WAS RECEIVED
    this.logger.log(Level.INFO, "[Auth] Received log entry. Logger: {}, Entry: {}", new Object[] { event.getLoggerName(), message });
    //HERE EDIT MESSAGE
    if(message.contains("issued server command: /")) {
        String[] array = message.split(": /");
        if(array[1].contains("ahoj")) {
            event.setMessage(array[0] + ": /KONECNETOFUNUGJE");
            //MODIFIED - TRUE
            return;
        }
    }

    //RESULT - COMING TO CustomConsoleFilter
    event.setMessage(message);
}

Error:

2020-09-02 20:33:08,402 Server thread ERROR Could not find class in ReflectionUtil.getCallerClass(2). java.lang.ClassNotFoundException: cz.ardno.auth.events.LogListener
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at org.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:141)
    at org.apache.logging.log4j.util.ReflectionUtil.getCallerClass(ReflectionUtil.java:141)
    at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:537)
    at cz.ardno.auth.events.LogListener.<init>(LogListener.java:12)
    at cz.ardno.auth.AuthManager$1.run(AuthManager.java:28)
    at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:76)
    at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:361)
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:739)
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406)
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
    at java.base/java.lang.Thread.run(Thread.java:834)




Aucun commentaire:

Enregistrer un commentaire