summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-12 23:47:12 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-12 23:47:12 +0000
commitdb2504596283d938961076069479f6ab47c89dc2 (patch)
tree915c0d74879b499bbf3a190dea2128f05207ba90 /java/sca/modules
parent7daf165684aa788a13955206e77fe777fbed7f6f (diff)
Use JDK Logger for Jetty
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@824543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java82
-rw-r--r--java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java7
2 files changed, 54 insertions, 35 deletions
diff --git a/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java b/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java
index 1ecf1bca1b..be56bdb682 100644
--- a/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java
+++ b/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java
@@ -18,6 +18,8 @@
*/
package org.apache.tuscany.sca.http.jetty;
+import java.util.logging.Level;
+
import org.mortbay.log.Logger;
/**
@@ -26,62 +28,80 @@ import org.mortbay.log.Logger;
* @version $Rev$ $Date$
*/
public class JettyLogger implements Logger {
+ private java.util.logging.Logger jdkLogger;
- private boolean debugEnabled;
+ public JettyLogger() {
+ this(JettyLogger.class.getName());
+ }
- public boolean isDebugEnabled() {
- return debugEnabled;
+ public JettyLogger(String name) {
+ jdkLogger = java.util.logging.Logger.getLogger(name);
}
- public void setDebugEnabled(boolean debugEnabled) {
- this.debugEnabled = debugEnabled;
+ /**
+ * @param jdkLogger
+ */
+ public JettyLogger(java.util.logging.Logger jdkLogger) {
+ super();
+ this.jdkLogger = jdkLogger;
}
- public void info(String msg, Object arg0, Object arg1) {
- if (debugEnabled) {
- System.err.println(":INFO: " + format(msg, arg0, arg1));
- }
+ public String getName() {
+ return jdkLogger.getName();
+ }
+
+ public void debug(String msg) {
+ jdkLogger.log(Level.FINE, msg);
}
public void debug(String msg, Throwable th) {
- if (debugEnabled) {
- System.err.println(":DEBUG: " + msg);
- th.printStackTrace();
- }
+ jdkLogger.log(Level.FINE, msg, th);
}
public void debug(String msg, Object arg0, Object arg1) {
- if (debugEnabled) {
- System.err.println(":DEBUG: " + format(msg, arg0, arg1));
- }
+ jdkLogger.log(Level.FINE, format(msg, arg0, arg1));
}
- public void warn(String msg, Object arg0, Object arg1) {
- if (debugEnabled) {
- System.err.println(":WARN: " + format(msg, arg0, arg1));
- }
+ public Logger getLogger(String name) {
+ return new JettyLogger(name);
}
- public void warn(String msg, Throwable th) {
- if (debugEnabled) {
- System.err.println(":WARN: " + msg);
- th.printStackTrace();
- }
+ public void info(String msg) {
+ jdkLogger.log(Level.INFO, msg);
}
- public Logger getLogger(String name) {
- return this;
+ public void info(String msg, Object arg0, Object arg1) {
+ jdkLogger.log(Level.INFO, format(msg, arg0, arg1));
+ }
+
+ public boolean isDebugEnabled() {
+ return jdkLogger.isLoggable(Level.FINE);
+ }
+
+ public void setDebugEnabled(boolean enabled) {
+ jdkLogger.setLevel(Level.FINE);
+ }
+
+ public void warn(String msg) {
+ jdkLogger.log(Level.WARNING, msg);
+ }
+
+ public void warn(String msg, Object arg0, Object arg1) {
+ jdkLogger.log(Level.WARNING, format(msg, arg0, arg1));
+ }
+
+ public void warn(String msg, Throwable th) {
+ jdkLogger.log(Level.WARNING, msg, th);
}
private String format(String msg, Object arg0, Object arg1) {
int i0 = msg.indexOf("{}");
int i1 = i0 < 0 ? -1 : msg.indexOf("{}", i0 + 2);
- if (arg1 != null && i1 >= 0) {
+
+ if (arg1 != null && i1 >= 0)
msg = msg.substring(0, i1) + arg1 + msg.substring(i1 + 2);
- }
- if (arg0 != null && i0 >= 0) {
+ if (arg0 != null && i0 >= 0)
msg = msg.substring(0, i0) + arg0 + msg.substring(i0 + 2);
- }
return msg;
}
}
diff --git a/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java b/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
index f57e189344..b966e38a29 100644
--- a/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
+++ b/java/sca/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
@@ -509,12 +509,11 @@ public class JettyServer implements ServletHost, LifeCycleListener {
public void start() {
try {
- jettyLogger = Log.getLog();
+ jettyLogger = new JettyLogger(logger);
+ Log.setLog(jettyLogger);
} catch (Throwable e) {
// Ignore
- } finally {
- Log.setLog(new JettyLogger());
- }
+ }
}
}