[logback-dev] svn commit: r1002 - logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Sat Nov 25 14:20:21 CET 2006
Author: ceki
Date: Sat Nov 25 14:20:21 2006
New Revision: 1002
Added:
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java
- copied, changed from r1001, /logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java
Removed:
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java
Modified:
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
Log:
- Print stack trace in case of parsing problems of the joran config file
- RequestLogRegistry instead of RequestLogMapper
- print Status list only in case of errors or warnings
Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java (original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java Sat Nov 25 14:20:21 2006
@@ -14,6 +14,7 @@
import ch.qos.logback.core.ContextBase;
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.filter.Filter;
+import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.spi.AppenderAttachable;
import ch.qos.logback.core.spi.AppenderAttachableImpl;
import ch.qos.logback.core.spi.FilterAttachable;
@@ -21,6 +22,7 @@
import ch.qos.logback.core.spi.FilterReply;
import ch.qos.logback.core.status.ErrorStatus;
import ch.qos.logback.core.status.InfoStatus;
+import ch.qos.logback.core.status.Status;
import ch.qos.logback.core.status.WarnStatus;
import ch.qos.logback.core.util.StatusPrinter;
@@ -135,7 +137,8 @@
aai.appendLoopOnAppenders(accessEvent);
}
- public void start() throws Exception {
+ public void start() {
+
if (filename == null) {
String jettyHomeProperty = System.getProperty("jetty.home");
@@ -149,8 +152,12 @@
if (configFile.exists()) {
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(this);
- jc.doConfigure(filename);
- StatusPrinter.print(getStatusManager());
+ try {
+ jc.doConfigure(filename);
+ } catch (JoranException e) {
+ e.printStackTrace(System.out);
+ }
+
} else {
getStatusManager().add(
new ErrorStatus("[" + filename + "] does not exist", this));
@@ -159,9 +166,13 @@
if (getName() == null) {
setName("LogbackRequestLog");
}
- RequestLogMapper.addRequestLog(this);
+ RequestLogRegistry.register(this);
getStatusManager().add(
new InfoStatus("RequestLog added to RequestLogMapper with name: " + getName(), this));
+
+ if(getStatusManager().getLevel() != Status.INFO) {
+ StatusPrinter.print(getStatusManager());
+ }
}
public void stop() throws Exception {
Copied: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java (from r1001, /logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java)
==============================================================================
--- /logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogMapper.java (original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java Sat Nov 25 14:20:21 2006
@@ -3,16 +3,16 @@
import java.util.HashMap;
import java.util.Map;
-public class RequestLogMapper {
+public class RequestLogRegistry {
- private static Map<String, RequestLogImpl> requestLogMap = new HashMap<String, RequestLogImpl>();
+ private static Map<String, RequestLogImpl> requestLogRegistry = new HashMap<String, RequestLogImpl>();
- public static void addRequestLog(RequestLogImpl requestLogImpl) {
- requestLogMap.put(requestLogImpl.getName(), requestLogImpl);
+ public static void register(RequestLogImpl requestLogImpl) {
+ requestLogRegistry.put(requestLogImpl.getName(), requestLogImpl);
}
public static RequestLogImpl get(String key) {
- return requestLogMap.get(key);
+ return requestLogRegistry.get(key);
}
}
More information about the logback-dev
mailing list