#How do I fix this logger thingy issue?

161 messages · Page 1 of 1 (latest)

topaz trail
#

I had logback & JDA installed, and there we're no issues whatsoever & it was able to detect the logger (logback) but when I installed DIH4JDA and finally set it up, it doesn't detect any loggers/logbacks whatsoever, and prints out Failed to load class "org.slf4j.impl.StaticLoggerBinder". Defaulting to no-operation (NOP) logger implementation. without printing Login successful! so, how do I fix this?

What I expect:
Logback logger stuff to work, without printing the Failed to load class "org.slf4j.impl.StaticLoggerBinder". Defaulting to no-operation (NOP) logger implementation. errors, and printing out Login successful!

Reality:
Logback doesn't work & the console instead errors: Failed to load class "org.slf4j.impl.StaticLoggerBinder". Defaulting to no-operation (NOP) logger implementation. & doesn't print: Login successful!, even when the login is successful.

winged girderBOT
#

Hey, @topaz trail!
Please remember to /close this post once your question has been answered!

burnt pulsar
#

Is slf4j-api in your dependencies?

topaz trail
#

like, in the build.gradle?

#

if so, then no

burnt pulsar
#

try adding it

topaz trail
#

still the same results

feral wasp
#

Yeah because its already in jda as a sub dependency

topaz trail
#

o

feral wasp
#

Have you tried to configure logback via the .xml file?

topaz trail
#

so I can just uh, remove the slf4j thing in my dependencies {}?

topaz trail
feral wasp
feral wasp
#

And what version of dih4jda do you use?

topaz trail
#

no wait

topaz trail
#

not DIH4JDA's

feral wasp
feral wasp
feral wasp
topaz trail
feral wasp
#

Mhh ok let me just check a few thins

#

Ok do you have logback or logback classic as the dependency?

burnt pulsar
#

If you add slf4j-simple, does it work?
Just for testing, you can remove it afterwards

feral wasp
#

Try replacing it with:
ch.qos.logback:logback-classic:1.4.4

feral wasp
burnt pulsar
feral wasp
topaz trail
#

yep yep came back

#

not tryna be rude or anything

topaz trail
burnt pulsar
feral wasp
#

But first try the solution from @burnt pulsar please

topaz trail
burnt pulsar
#

and - what happens?

#

Does the error disappear or is it still there

topaz trail
topaz trail
burnt pulsar
#

How do you start it?

topaz trail
#

clicking the run button in the top right corner of intelliJ IDEA

burnt pulsar
#

What are the versions of slf4j-simple and slf4j-api? Are they the same?

burnt pulsar
topaz trail
topaz trail
#

build.gradle:

plugins {
    id 'application'
    id 'com.github.johnrengelman.shadow' version '5.2.0'
}

mainClassName = 'com.hedreon.hedreobot.Bot'

version '1.0'
def jdaVersion = '5.0.0-alpha.22'
def dih4jdaVersion = '1.6.0-beta.2'
def envVersion = '2.2.4'

sourceCompatibility = targetCompatibility = 1.8

repositories {
    mavenCentral()
    maven {
        url "https://m2.dv8tion.net/releases"
    }
}

dependencies {
    implementation("net.dv8tion:JDA:$jdaVersion")
    implementation("io.github.cdimascio:dotenv-java:$envVersion")
    implementation("xyz.dynxsty:dih4jda:$dih4jdaVersion")
    implementation("ch.qos.logback:logback-classic:1.4.4")
}

compileJava.options.encoding = 'UTF-8'
#

if you want the main class, just lmk

burnt pulsar
#

How did you add slf4j-simple?

topaz trail
#

using the same format as "everyone else", as in, on how the other implementations we're formatted, with the brackets, ()

burnt pulsar
#

you need to add it to the build.gradle

topaz trail
#

the dependencies table

#

like

feral wasp
#

Pls add

repositories {
maven {url "https://jitpack.io"}
}

And remove the jda dependency should be included in dih4jda

topaz trail
#

a table is like,

table {
  stuff here
}
topaz trail
#

and thats what I meant by table

feral wasp
#

And one question. The bot starts but the logging doesn’t work right?

feral wasp
#

Ok that’s good

topaz trail
#

including the logging of if the login was successful or not

topaz trail
feral wasp
topaz trail
#

did that

#

should I remove the uh,

maven {
        url "https://m2.dv8tion.net/releases"
    }

repository?

feral wasp
#

No just leave it

topaz trail
#

ok

topaz trail
#

I'm starting to have a feeling it's on the main class

feral wasp
#

Then show us the main class

#

But the logger says that he could not find the class but show us the class and we'll see

topaz trail
#

no it says "Failed to load class "org.slf4j.impl.StaticLoggerBinder"."

#

I don't think org.slf4j.impl.StaticLoggerBinder is my class

#

but anyway

#

Bot.java:

package com.hedreon.hedreobot;

import io.github.cdimascio.dotenv.Dotenv;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import xyz.dynxsty.dih4jda.DIH4JDA;
import xyz.dynxsty.dih4jda.DIH4JDABuilder;
import xyz.dynxsty.dih4jda.exceptions.DIH4JDAException;

public class Bot {
    public static void main(String[] args) throws DIH4JDAException {
        Dotenv env = Dotenv.configure().load();
        String loginVar = env.get("TOKEN");

        JDA jda = JDABuilder.createLight(loginVar).build();

        DIH4JDA dih4JDA = DIH4JDABuilder.setJDA(jda).build();
    }

//    @Override
//    public void onMessageReceived(MessageReceivedEvent event) {
//        if (event.getAuthor().isBot()) return;
//
//        Message message = event.getMessage();
//        String content = message.getContentRaw();
//
//        if (content.equals("!ping")) {
//            MessageChannel channel = event.getChannel();
//            channel.sendMessage("Pong!").queue();
//        }
//    }
}
#

it's messy

#

the commented out code is old

#

gonna replace it with the slash commands version, once I have the logging fixed

feral wasp
topaz trail
feral wasp
#

No you main class seems fine

topaz trail
#

u sure?

feral wasp
#

Yeah sure

feral wasp
topaz trail
#

ok

feral wasp
#

Can you please update the shadow plugin to 7.1.2 then build a shadow jar and execute it via the commandline and see if the same error is appearing?

topaz trail
#

damn bro

#

didn't realise my one is like

#

a million years behind

topaz trail
# feral wasp Can you please update the shadow plugin to 7.1.2 then build a shadow jar and exe...

updated it, compiled it to shadowJar, and ran java -jar <myshadowjar> and this happened:

Exception in thread "main" io.github.cdimascio.dotenv.DotenvException: Could not find /.env on the classpath
        at io.github.cdimascio.dotenv.internal.ClasspathHelper.loadFileFromClasspath(ClasspathHelper.java:26)
        at io.github.cdimascio.dotenv.internal.DotenvReader.read(DotenvReader.java:57)
        at io.github.cdimascio.dotenv.internal.DotenvParser.lines(DotenvParser.java:65)
        at io.github.cdimascio.dotenv.internal.DotenvParser.parse(DotenvParser.java:47)
        at io.github.cdimascio.dotenv.DotenvBuilder.load(DotenvBuilder.java:77)
        at com.hedreon.hedreobot.Bot.main(Bot.java:12)
        Suppressed: io.github.cdimascio.dotenv.DotenvException: Could not find .\.env on the file system (working directory: D:\_DEV\HedreoBot\build\libs)
                at io.github.cdimascio.dotenv.internal.DotenvReader.read(DotenvReader.java:62)

#

it does find it when I run it

#

but when I do that stuff it doesn't

#

because the .env file isn't compiled to the shadow jar

#

probably for good reasons - like security reasons

feral wasp
#

Then try to run the shadow jar. I dont know how to fix that with the .env file.
I try to recreate the issue tomorrow and maybe fix the bug in dih4jda if it dih4jda faults

topaz trail
feral wasp
topaz trail
feral wasp
topaz trail
#

where the build.gradle file is stored

#

where the settings.gradle is stored

feral wasp
topaz trail
#

so ur saying it's smart to move the .env to there?

feral wasp
#

Just place the token directly in the source code just for testing and then try it again

vivid hollow
#

no

#

copy the file to /build/libs and it'll work

feral wasp
vivid hollow
#

@wind panther lurking

wind panther
#

I like reading stuff I dont understand

topaz trail
vivid hollow
#

can you show where you copied it

topaz trail
#

Here's the full:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.
vivid hollow
#

I thought you meant the .env stuff

topaz trail
topaz trail
feral wasp
#

And this only happens when you adf dih4jda to your project?

topaz trail
#

if I undo all those changes and revert back to the time when I just had JDA

#

then yeah, I believe so, I believe the logging works perfectly

feral wasp
#

Which java version to you use?

topaz trail
#

Eclipse Temurin Adoptium 17

#

so java 17

feral wasp
#

Mhhh ok

topaz trail
#

and not ur uzual zava 11 or 8

feral wasp
#

I have to admit i dont know what to do anymore. :/

topaz trail
#

maybe dynasty can help me

#

tho idk

#

obviously nobody should ping him/her

#

when (s)he is probably sleeping or away

feral wasp
#

He is not at home I believe.
I can text you tomorrow in the evening because atm I am also not at home

topaz trail
#

ok

topaz trail
#

and not pc gamr

feral wasp
#

Maybe someone else can help because I don’t think it has to do with dih4jda

feral wasp
topaz trail
#

he invented 'easy-to-read' crash reports for java (with jokes sprinkled in between)

feral wasp
#

Then ask notch 😵‍💫

topaz trail
#

even if I did try to ask notch

#

he wouldnt respond

#

of course

feral wasp
#

Maybe you dont know for sure

topaz trail
#

I actually dont know why he doesn't respond when he doesn't work at minecraft, mojang or microsoft anymore

feral wasp
#

No but for real if I remember I text you tomorrow but atm I can not help you sorry

topaz trail
#

yee I understand

topaz trail
#

Issue fixed by @feral wasp