1

I'm working on a Minecraft plugin and want to use Javalin. I can easily disable the Javali-logging with JavalinLogger.enabled = false but I can't disable the jetty log.

I always get the following output when starting the Javalin server:

[22:24:32 INFO]: [org.eclipse.jetty.server.Server] jetty-11.0.12; built: 2022-09-14T02:38:00.723Z; git: d5b8c29485f5f56a14be5f20c2ccce81b93c5555; jvm 17+35-LTS-2724 [22:24:32 INFO]: [org.eclipse.jetty.server.session.DefaultSessionIdManager] Session workerName=node0 [22:24:32 INFO]: [org.eclipse.jetty.server.handler.ContextHandler] Started i.j.j.@3293e900{/,null,AVAILABLE} [22:24:32 INFO]: [org.eclipse.jetty.server.AbstractConnector] Started ServerConnector@4c57aa18{HTTP/1.1, (http/1.1)}{0.0.0.0:80} [22:24:32 INFO]: [org.eclipse.jetty.server.Server] Started Server@34f89e1c{STARTING}[11.0.12,sto=0] @4657581ms 

These are my dependencies in my pom.xml:

<dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot-api</artifactId> <version>1.19.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> <dependency> <groupId>io.javalin</groupId> <artifactId>javalin</artifactId> <version>5.1.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>2.0.3</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.13.4.2</version> </dependency> 

I already tried the following:

  • Setting different system properties e.g. org.eclipse.jetty.LEVEL
  • Adding slf4j-simple and an simplelogger.properties
    • Tried the same thing with log4j
    • And with logback

Edit 1: After just implementing the source of slf4j-simple I realized that jetty is not using that at all. No Instance of SimpleLogger gets created. But if I just remove the slf4j provider entirely jetty doesn't log anymore but Javalin is throwing a huge warning that no providers were found

Edit 2: Steps to recreate the problem

  1. Create a new Project inside IntelliJ with the "Minecraft" plugin
  2. Choose Spigot and Version 1.19.2
  3. I edited two Files:

pom.xml, Added following dependencies:

<dependency> <groupId>io.javalin</groupId> <artifactId>javalin</artifactId> <version>5.1.2</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>2.0.3</version> </dependency> 

The "main" java file that has the onEnable() method

@Override public void onEnable() { // Plugin startup logic System.setProperty(org.slf4j.simple.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "OFF"); JavalinLogger.enabled = false; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(this.getClassLoader()); Javalin app = Javalin.create(); Thread.currentThread().setContextClassLoader(classLoader); app.get("/", ctx -> ctx.result("Hello World!")); app.start(); } 

This creates the following output (on Paper 1.19.2):

[02:39:47 INFO]: [Javalintest] Enabling Javalintest v1.0-SNAPSHOT [02:39:48 INFO]: [org.eclipse.jetty.server.Server] jetty-11.0.12; built: 2022-09-14T02:38:00.723Z; git: d5b8c29485f5f56a14be5f20c2ccce81b93c5555; jvm 17+35-LTS-2724 [02:39:48 INFO]: [org.eclipse.jetty.server.session.DefaultSessionIdManager] Session workerName=node0 [02:39:48 INFO]: [org.eclipse.jetty.server.handler.ContextHandler] Started i.j.j.@2f6e3e6c{/,null,AVAILABLE} [02:39:48 INFO]: [org.eclipse.jetty.server.AbstractConnector] Started ServerConnector@17e2d1ec{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} [02:39:48 INFO]: [org.eclipse.jetty.server.Server] Started Server@5f91e5cc{STARTING}[11.0.12,sto=0] @14943ms [02:39:48 INFO]: Running delayed init tasks [02:39:48 INFO]: Done (4.288s)! For help, type "help" [02:39:48 INFO]: Timings Reset 

1 Answer 1

1

Spigot / Bukkit uses java.util.logging for it's environment (which can easily be different than what your standalone environment is using).

The typical way to access THE logger in Spigot / Bukkit is via ..

Logger logger = Bukkit.getLogger(); logger.info("This is my log message"); 

There is only 1 Logger when you are running in Spigot / Bukkit.

This logger is a java.util.logging.Logger instance.

See: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Bukkit.java#819

That means you have to have a valid environment for logging for slf4j and in turn Jetty.

To do that, ensure that your Spigot / Bukkit environment has the slf4j-jdk14 dependency present, along with the slf4j-api dependency. Be careful these might be present courtesy of a different pluging running in your Spigot / Bukkit environment, don't stomp on them.

Now, once you have a valid setup for the dependencies, you'll need to configure what that logging is doing.

The simplest solution is to just set the org.eclipse.jetty tree to a more restricted level.

// using java.util.logging Logger logger = Logger.getLogger("org.eclipse.jetty"); logger.setLevel(Level.WARN); // good idea to see bad issues. 

Keep in mind that you are operating with many other plugins in your Spigot / Bukkit environment, another plugin could have initialized javalin before you, rendering the above line of code useless (as it happens far too late).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the explanation but I still get the log output. After many hours of troubleshooting, I ended up editing slf4j and javalin by myself to suppress the log messages.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.