* Reimplement Jetty log sedating by introducing a new private Log class that
reduces the log verbosity for levels DEBUG and TRACE. This is a fix for the fix for bug 560 <http://helma.org/bugs/show_bug.cgi?id=560>, which resulted in Jetty logfiles to be written to a subdirectory called "console".
This commit is contained in:
parent
61b41e098a
commit
8cffcf5b57
2 changed files with 108 additions and 6 deletions
|
@ -55,6 +55,9 @@ public class Logger implements Log {
|
||||||
// periods of inactivity
|
// periods of inactivity
|
||||||
long lastMessage = System.currentTimeMillis();
|
long lastMessage = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// sedated log instance for jetty
|
||||||
|
private Log sedatedLog = new SedatedLog();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* zero argument constructor, only here for FileLogger subclass
|
* zero argument constructor, only here for FileLogger subclass
|
||||||
*/
|
*/
|
||||||
|
@ -88,7 +91,7 @@ public class Logger implements Log {
|
||||||
else if ("error".equalsIgnoreCase(level))
|
else if ("error".equalsIgnoreCase(level))
|
||||||
logLevel = ERROR;
|
logLevel = ERROR;
|
||||||
else if ("fatal".equalsIgnoreCase(level))
|
else if ("fatal".equalsIgnoreCase(level))
|
||||||
logLevel = FATAL;
|
logLevel = FATAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,4 +305,98 @@ public class Logger implements Log {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return a "quiet" version of this log that routes debug() output to trace()
|
||||||
|
* @return a possibly less verbose version of this log.
|
||||||
|
*/
|
||||||
|
protected Log getSedatedLog() {
|
||||||
|
return sedatedLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A inner class that "calms down" logging output by routing debug() output
|
||||||
|
* to trace(). This is useful for software like Jetty, which has really
|
||||||
|
* verbose output at DEBUG level (dumps whole HTTP request and response headers).
|
||||||
|
* You can enable that output by setting the log level to TRACE.
|
||||||
|
*/
|
||||||
|
class SedatedLog implements Log {
|
||||||
|
|
||||||
|
public void debug(Object o) {
|
||||||
|
// Route debug() to trace()
|
||||||
|
Logger.this.trace(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void debug(Object o, Throwable t) {
|
||||||
|
// Route debug() to trace()
|
||||||
|
Logger.this.trace(o, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(Object o) {
|
||||||
|
Logger.this.error(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void error(Object o, Throwable t) {
|
||||||
|
Logger.this.error(o, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(Object o) {
|
||||||
|
Logger.this.fatal(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fatal(Object o, Throwable t) {
|
||||||
|
Logger.this.fatal(o, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(Object o) {
|
||||||
|
Logger.this.info(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void info(Object o, Throwable t) {
|
||||||
|
Logger.this.info(o, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(Object o) {
|
||||||
|
// swallow trace()
|
||||||
|
}
|
||||||
|
|
||||||
|
public void trace(Object o, Throwable t) {
|
||||||
|
// swallow trace()
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(Object o) {
|
||||||
|
Logger.this.warn(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void warn(Object o, Throwable t) {
|
||||||
|
Logger.this.warn(o, t);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDebugEnabled() {
|
||||||
|
// Route debug() to trace()
|
||||||
|
return Logger.this.isTraceEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isErrorEnabled() {
|
||||||
|
return Logger.this.isErrorEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFatalEnabled() {
|
||||||
|
return Logger.this.isFatalEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInfoEnabled() {
|
||||||
|
return Logger.this.isInfoEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTraceEnabled() {
|
||||||
|
// swallow trace()
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWarnEnabled() {
|
||||||
|
return Logger.this.isWarnEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,11 +63,16 @@ public class Logging extends LogFactory {
|
||||||
if (logname == null) {
|
if (logname == null) {
|
||||||
throw new LogConfigurationException("No logname specified!");
|
throw new LogConfigurationException("No logname specified!");
|
||||||
}
|
}
|
||||||
|
if ("console".equals(logdir)) {
|
||||||
if ("console".equals(logdir) && !logname.startsWith("org.mortbay.")) {
|
if (logname.startsWith("org.mortbay."))
|
||||||
return getConsoleLog();
|
return getConsoleLog().getSedatedLog();
|
||||||
|
else
|
||||||
|
return getConsoleLog();
|
||||||
} else {
|
} else {
|
||||||
return getFileLog(logname);
|
if (logname.startsWith("org.mortbay."))
|
||||||
|
return getFileLog(logname).getSedatedLog();
|
||||||
|
else
|
||||||
|
return getFileLog(logname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +80,7 @@ public class Logging extends LogFactory {
|
||||||
* Get a logger to System.out.
|
* Get a logger to System.out.
|
||||||
* @return a logger that writes to System.out
|
* @return a logger that writes to System.out
|
||||||
*/
|
*/
|
||||||
public static Log getConsoleLog() {
|
public static Logger getConsoleLog() {
|
||||||
ensureRunning();
|
ensureRunning();
|
||||||
return consoleLog;
|
return consoleLog;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue