How to disable Javalin logging

Luís Soares :

I'd like to turn off this logging under Javalin:

[main] INFO org.eclipse.jetty.util.log - Logging initialized @850ms to org.eclipse.jetty.util.log.Slf4jLog
[main] INFO io.javalin.Javalin - Starting Javalin ...
[main] INFO io.javalin.Javalin - Listening on http://localhost:8003/
[main] INFO io.javalin.Javalin - Javalin started in 334ms \o/
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[main] INFO io.javalin.Javalin - Starting Javalin ...
[main] INFO io.javalin.Javalin - Listening on http://localhost:6667/
[main] INFO io.javalin.Javalin - Javalin started in 7ms \o/
[main] INFO io.javalin.Javalin - Stopping Javalin ...
[main] INFO io.javalin.Javalin - Javalin has stopped
[main] INFO io.javalin.Javalin - Stopping Javalin ...
[main] INFO io.javalin.Javalin - Javalin has stopped

... but Javalin does not seem to have a way to turn these logs off. Is there a way? thanks

Alexey Romanov :

Javalin uses SLF4J for logging (you can even see the class name Slf4jLog in the first message). This is an abstracton which can work with many different actual implementations, so the first step is to find which one your project uses. List the dependencies (Gradle, Maven) and look for slf4j-<something> (except slf4j-api) or logback-classic. Then look at https://www.slf4j.org/manual.html#swapping for the one you found and find how to configure it to set to a higher level than INFO.

E.g. if you followed

Javalin does not have a logger included, which means that you have to add your own logger. If you don’t know/care a lot about Java loggers, the easiest way to fix this is to add the following dependency to your project:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.26</version>
</dependency>

from the Javalin documentation, see How to configure slf4j-simple.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326760&siteId=1