Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jetty: how to disable logging?

Tags:

logging

jetty

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?

like image 539
user257087 Avatar asked Jan 22 '10 20:01

user257087


1 Answers

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) { }
}
like image 78
Chris Martin Avatar answered Oct 22 '22 18:10

Chris Martin