Jetty: how to disable logging?

user257087 picture user257087 · Jan 22, 2010 · Viewed 18.7k times · Source

I am trying to embed Jetty 6.1 in another program. Jetty is dumping INFO-log information and I need to turn it off. Is there a simple way to disable logging programmaticaly?

Answer

Chris Martin picture Chris Martin · Sep 27, 2013

A more concise version of Jeff Chern's answer:

org.eclipse.jetty.util.log.Log.setLog(new NoLogging())

.

import org.eclipse.jetty.util.log.Logger;

public class NoLogging implements Logger {
    @Override public String getName() { return "no"; }
    @Override public void warn(String msg, Object... args) { }
    @Override public void warn(Throwable thrown) { }
    @Override public void warn(String msg, Throwable thrown) { }
    @Override public void info(String msg, Object... args) { }
    @Override public void info(Throwable thrown) { }
    @Override public void info(String msg, Throwable thrown) { }
    @Override public boolean isDebugEnabled() { return false; }
    @Override public void setDebugEnabled(boolean enabled) { }
    @Override public void debug(String msg, Object... args) { }
    @Override public void debug(Throwable thrown) { }
    @Override public void debug(String msg, Throwable thrown) { }
    @Override public Logger getLogger(String name) { return this; }
    @Override public void ignore(Throwable ignored) { }
}