Search code examples
javarestletrestlet-2.0

How can I disable logging in Restlet 2.0?


I simply want to disable Restlet's logging to stdout/stderr in my project and forward all Restlet logging through the SLF4J facade provided by org.restlet.ext.slf4j. Is there an easy way to do this?


Solution

  • You first must configure SLF4J to intercept all of Restlet's calls to the java.util.logging APIs and map them into calls on the SLF4J facade's APIs instead. You simply do this by putting jul-to-slf4j.jar in your classpath, as @Bruno noted.

    Second, you have to configure the SLF4J facade to forward its API calls on to a logging implementation to do the actual log message generation. To use the Logback logging implementation, you drop logback-classic.jar into your classpath

    Finally, you have to configure your selected logging implementation. If you're using Logback, you can adjust the logging level of individual Loggers using XML.

    We're using SLF4J with Restlet, and really like how SLF4J unifies all the different logging APIs into one. It's very nice.

    Edit 29 April 2019: Be sure to check the comments from @NaftuliKay and @stempler, Restlet has doubtless changed over the last decade!