B4J Question Server logging & slf4j [SOLVED]

tchart

Well-Known Member
Licensed User
Longtime User
Im using a library that included slf4j as a dependency. What Ive noticed is that when I include this library my (Jetty) Server starts logging at the debug level.

According to the Jetty documentation documentation this is expected;

If the class org.slf4j.Logger exists in server classpath, the Jetty implementation becomes org.eclipse.jetty.util.log.Slf4jLog.

The fix is to force the jetty logging implementation back to StdErrLog, which you can do by setting the following in the jetty-logging.properties file like this;

org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog

What Im after is a way to do this via code.

Ive tried several variations of this via JavaObject but I cant get it to work (code below give an error java.lang.RuntimeException: Field: org.eclipse.jetty.util.log.class not found in: anywheresoftware.b4j.object.ServerWrapper)

B4X:
Dim jo As JavaObject = srvr   
 jo.SetField("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog")

Does anyone know how I can access set this property?
 

tchart

Well-Known Member
Licensed User
Longtime User
And of course I find the answer a minute after posting!!!

This must be done before the Initialize

B4X:
SetSystemProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog") 'MUST DO BEFORE Initialize
srvr.Initialize("srvr")
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…