Zekhap_N_A
(Zekhap N/A)
1
Hello,
(Java, Maven, Minecraft Paper 1.19.2)
Since i’ve upgraded mongodb-driver-sync to 4.7.2 my console have been spamming logs from
- org.mongodb.driver.cluster
- org.mongodb.driver.connection
- org.mongodb.driver.client
Before i could go in the Loggers file and edit the
private static final boolean USE_SLF4J = false
and that fixed my problem.
Now i cant do that anymore.
What i currently have installed
- slf4j-api: 2.0.4
- log4j-api: 2.19.0
- logback-classic: 1.4.5
- log4j-slf4j2-impl: 2.19.0
- morphia-core: 2.2.9
- mongodb-driver-core: 4.7.2
- mongodb-driver-sync: 4.7.2
I’ve installed those logging things but it still does not hide(not sure if im doing right) i read the documentation also but i don’t get it.
- slf4j-api: 2.0.4
- log4j-api: 2.19.0
- logback-classic: 1.4.5
- log4j-slf4j2-impl: 2.19.0
Tried to use this also but noting
<logger name="org.mongodb.driver.client" level="OFF" />
Logger.getLogger("org.mongodb.driver").setLevel(Level.OFF);
I don’t really want to downgrade again just to make the console hide.
Zekhap_N_A
(Zekhap N/A)
3
- What version of the driver did you upgrade from?
I actually had the mongo-java-driver: 3.12.4 installed. But now when i revert the changes it still prints the logging. Must be java then since i updated that also when i updated the drivers. But i used this to hide the logging Here
- Are you trying to disable all SLF4J-based logging, or just logging from the driver?
Since i’m using the Listeners to log the connections i don’t really want the drive to print in the console that it connects to the server. So yes just the driver. I tried to use slf4j before but whatever i did, nothing happend.
.applyToServerSettings(builder -> {
builder.addServerMonitorListener(new MongoListener(this));
});
But i do wish there was like an option to just add a line and the drive wont print anything in the console
MongoClientSettings.Builder options = MongoClientSettings.builder()
.disableLogging(true); //someting like this
I hope you understand what i mean 
I should have asked which logging system that you are actually using. But given what you have installed, it sounds like Log4J. Assuming that, what you should do is
- Remove any other SLF4J bridge library. From what I can tell, that would be logback-classic
- Configure log4j to disable all driver logging. Looking at Log4J documentation, that would look something like this
<Logger name="org.mongodb.driver" level="off" additivity="false">
<AppenderRef ref="Out"/>
</Logger>
If you’re using a different logger than Log4J, it will be a bit different, but same idea.
Good luck,
Jeff
1 Like
Zekhap_N_A
(Zekhap N/A)
5
Remove any other SLF4J bridge library. From what I can tell, that would be logback-classic
I removed the logback-classic.
Configure log4j to disable all driver logging. Looking at Log4J documentation, that would look something like this
I looked at the Log4J docs, i tested with the files log4j.xml and log4j2.xml inside the src/resource/
I compiled it to a .jar file after and the .xml file was there atleast, but it did not work either.
Do i need to write some code to make it work / did i put the files at wrong place?
This is the logging dependency’s i have now.
- slf4j-api:2.0.4
- log4j-api:2.19.0
- log4j-core:2.19.0
- log4j-slf4j2-impl:2.19.0
When i looked through the minecraft paper .pom files they had the libaries
- slf4j-api:1.8.0-beta4
- log4j-api: 2.17.1
Zekhap_N_A
(Zekhap N/A)
6
Okey everything works until i add the minecraft paper inside the .pom.
Then it stops.
But… if i use the System.out.println(“test”); it has edited my output atleast
not it is 00:00:00 INFO]: [Plugin] [STDOUT] TEST
Before it was only 00:00:00 INFO]: [Plugin] TEST
My log4j2.xml right now
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Loggers>
<Logger name="org.mongodb.driver" level="off" additivity="false">
<AppenderRef ref="Out"/>
</Logger>
</Loggers>
</Configuration>
I tested with
- org.mongodb.driver.client
- org.mongodb.driver.*