[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_1.0.0-4-geeca3cc

Gitbot git-noreply at pixie.qos.ch
Tue Nov 1 22:03:08 CET 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  eeca3cce56c62bbda54d227e64ada15192e5fc27 (commit)
       via  92857cb9465756d8150091e5cefd64cde7a8b643 (commit)
      from  23f5ce557103d5e0c202d4e2cbd2172ce12a78d9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=eeca3cce56c62bbda54d227e64ada15192e5fc27
http://github.com/ceki/logback/commit/eeca3cce56c62bbda54d227e64ada15192e5fc27

commit eeca3cce56c62bbda54d227e64ada15192e5fc27
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Nov 1 22:02:37 2011 +0100

    fixing  LBACCESS-26

diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
index 9071b03..6066b4d 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java
@@ -14,10 +14,15 @@
 package ch.qos.logback.access.jetty;
 
 import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 
+import ch.qos.logback.core.status.InfoStatus;
+import ch.qos.logback.core.util.FileUtil;
 import ch.qos.logback.core.util.StatusPrinter;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.RequestLog;
@@ -118,6 +123,7 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
   AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
   FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
   String fileName;
+  String resource;
   boolean started = false;
   boolean quiet = false;
 
@@ -136,26 +142,23 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
     aai.appendLoopOnAppenders(accessEvent);
   }
 
+  private void addInfo(String msg) {
+    getStatusManager().add(new InfoStatus(msg, this));
+  }
+
+//  private void addWarn(String msg) {
+//    getStatusManager().add(new WarnStatus(msg, this));
+//  }
+  private void addError(String msg) {
+    getStatusManager().add(new ErrorStatus(msg, this));
+  }
+
   public void start() {
-    if (fileName == null) {
-      String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
-      if (OptionHelper.isEmpty(jettyHomeProperty)) {
-        getStatusManager().add(
-                new WarnStatus("[jetty.home] system property not set.", this));
-        fileName = DEFAULT_CONFIG_FILE;
-      } else {
-        fileName = jettyHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
-      }
-      getStatusManager().add(
-              new WarnStatus("fileName property not set. Assuming [" + fileName
-                      + "]", this));
-    }
-    File configFile = new File(fileName);
-    if (configFile.exists()) {
-      runJoranOnFile(configFile);
+    URL configURL = getConfigurationFileURL();
+    if (configURL != null) {
+      runJoranOnFile(configURL);
     } else {
-      getStatusManager().add(
-              new ErrorStatus("Could not find logback-access configuration file [" + fileName + "]", this));
+      addError("Could not find configuration file for logback-access");
     }
     if (!isQuiet()) {
       StatusPrinter.print(getStatusManager());
@@ -163,11 +166,38 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
     started = true;
   }
 
-  private void runJoranOnFile(File configFile) {
+  URL getConfigurationFileURL() {
+    if (fileName != null) {
+      addInfo("Will use configuration file [" + fileName + "]");
+      File file = new File(fileName);
+      if (!file.exists())
+        return null;
+      return FileUtil.fileToURL(file);
+    }
+    if (resource != null) {
+      addInfo("Will use configuration resource [" + resource + "]");
+      return this.getClass().getResource(resource);
+    }
+
+    String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
+    String defaultConfigFile = DEFAULT_CONFIG_FILE;
+    if (!OptionHelper.isEmpty(jettyHomeProperty)) {
+      defaultConfigFile = jettyHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
+    } else {
+      addInfo("[jetty.home] system property not set.");
+    }
+    File file = new File(defaultConfigFile);
+    addInfo("Assuming default configuration file ["+defaultConfigFile+"]");
+    if (!file.exists())
+      return null;
+    return FileUtil.fileToURL(file);
+  }
+
+  private void runJoranOnFile(URL configURL) {
     try {
       JoranConfigurator jc = new JoranConfigurator();
       jc.setContext(this);
-      jc.doConfigure(configFile);
+      jc.doConfigure(configURL);
       if (getName() == null) {
         setName("LogbackRequestLog");
       }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
index ee8d4d5..05bc439 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/FileUtil.java
@@ -19,12 +19,21 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLConnection;
 
 public class FileUtil {
 
 
+  public static URL fileToURL(File file) {
+    try {
+      return file.toURI().toURL();
+    } catch (MalformedURLException e) {
+      throw new RuntimeException("Unexpected exception on file ["+file+"]", e);
+    }
+  }
+
   static public boolean isParentDirectoryCreationRequired(File file) {
     File parent = file.getParentFile();
     if (parent != null && !parent.exists()) {

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=92857cb9465756d8150091e5cefd64cde7a8b643
http://github.com/ceki/logback/commit/92857cb9465756d8150091e5cefd64cde7a8b643

commit 92857cb9465756d8150091e5cefd64cde7a8b643
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Tue Nov 1 20:41:50 2011 +0100

    no ned for the jetty/v7 folder

diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/JettyServerAdapter.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/JettyServerAdapter.java
deleted file mode 100644
index b3813d8..0000000
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/JettyServerAdapter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- *   or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.access.jetty.v7;
-
-import ch.qos.logback.access.spi.ServerAdapter;
-import org.eclipse.jetty.http.HttpFields;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.Response;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A jetty specific implementation of the {@link ch.qos.logback.access.spi.ServerAdapter} interface.
- * <p>
- * <strong>Note</strong> that this implementation works with Jetty version 7.x.x.
- * For Jetty 6.x.x implementations, see {@link ch.qos.logback.access.jetty.JettyServerAdapter}.
- *
- * @author Sébastien Pennec
- * @author Ceki Gulcu
- */
-public class JettyServerAdapter implements ServerAdapter {
-
-  Request request;
-  Response response;
-
-  public JettyServerAdapter(Request jettyRequest, Response jettyResponse) {
-    this.request = jettyRequest;
-    this.response = jettyResponse;
-  }
-
-  public long getContentLength() {
-    return response.getContentCount();
-  }
-
-  public int getStatusCode() {
-    return response.getStatus();
-  }
-
-  public Map<String, String> buildResponseHeaderMap() {
-    Map<String, String> responseHeaderMap = new HashMap<String, String>();
-    HttpFields httpFields = response.getHttpFields();
-    Enumeration e = httpFields.getFieldNames();
-    while (e.hasMoreElements()) {
-      String key = (String) e.nextElement();
-      String value = response.getHeader(key);
-      responseHeaderMap.put(key, value);
-    }
-    return responseHeaderMap;
-  }
-
-}
\ No newline at end of file
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
deleted file mode 100644
index 91d82c9..0000000
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- *   or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.access.jetty.v7;
-
-import ch.qos.logback.access.joran.JoranConfigurator;
-import ch.qos.logback.access.spi.AccessEvent;
-import ch.qos.logback.access.spi.IAccessEvent;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.ContextBase;
-import ch.qos.logback.core.CoreConstants;
-import ch.qos.logback.core.filter.Filter;
-import ch.qos.logback.core.joran.spi.JoranException;
-import ch.qos.logback.core.spi.*;
-import ch.qos.logback.core.status.ErrorStatus;
-import ch.qos.logback.core.status.InfoStatus;
-import ch.qos.logback.core.status.WarnStatus;
-import ch.qos.logback.core.util.OptionHelper;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.RequestLog;
-import org.eclipse.jetty.server.Response;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * This class is logback's implementation of jetty's RequestLog interface. <p>
- * <p>
- * <strong>Note</strong> that this implementation works with Jetty version 7.x.x.
- * For Jetty 6.x.x implementations, see {@link ch.qos.logback.access.jetty.RequestLogImpl}.
- * <p>
- * This class can be seen as logback classic's LoggerContext. Appenders can be attached
- * directly to RequestLogImpl and RequestLogImpl uses the same StatusManager as
- * LoggerContext does. It also provides containers for properties. <p> To
- * configure jetty in order to use RequestLogImpl, the following lines must be
- * added to the jetty configuration file, namely <em>etc/jetty.xml</em>:
- *
- * <pre>
- *    <Ref id="requestLog">
- *      <Set name="requestLog">
- *        <New id="requestLogImpl" class="ch.qos.logback.access.jetty.v7.RequestLogImpl"></New>
- *      </Set>
- *    </Ref>
- * </pre>
- *
- * By default, RequestLogImpl looks for a logback configuration file called
- * logback-access.xml, in the same folder where jetty.xml is located, that is
- * <em>etc/logback-access.xml</em>. The logback-access.xml file is slightly
- * different than the usual logback classic configuration file. Most of it is
- * the same: Appenders and Layouts are declared the exact same way. However,
- * loggers elements are not allowed. <p> It is possible to put the logback
- * configuration file anywhere, as long as it's path is specified. Here is
- * another example, with a path to the logback-access.xml file.
- *
- * <pre>
- *    <Ref id="requestLog">
- *      <Set name="requestLog">
- *        <New id="requestLogImpl" class="ch.qos.logback.access.jetty.v7.RequestLogImpl"></New>
- *          <Set name="fileName">path/to/logback.xml</Set>
- *      </Set>
- *    </Ref>
- * </pre>
- *
- * <p> Here is a sample logback-access.xml file that can be used right away:
- *
- * <pre>
- *    <configuration>
- *      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- *        <layout class="ch.qos.logback.access.PatternLayout">
- *          <param name="Pattern" value="%date %server %remoteIP %clientHost %user %requestURL" />
- *        </layout>
- *      </appender>
- *
- *      <appender-ref ref="STDOUT" />
- *    </configuration>
- * </pre>
- *
- * <p> Another configuration file, using SMTPAppender, could be:
- *
- * <pre>
- *    <configuration>
- *      <appender name="SMTP" class="ch.qos.logback.access.net.SMTPAppender">
- *        <layout class="ch.qos.logback.access.PatternLayout">
- *          <param name="pattern" value="%remoteIP [%date] %requestURL %statusCode %bytesSent" />
- *        </layout>
- *        <param name="From" value="sender at domaine.org" />
- *        <param name="SMTPHost" value="mail.domain.org" />
- *         <param name="Subject" value="Last Event: %statusCode %requestURL" />
- *         <param name="To" value="server_admin at domain.org" />
- *      </appender>
- *      <appender-ref ref="SMTP" />
- *    </configuration>
- * </pre>
- *
- * @author Ceki Gülcü
- * @author Sébastien Pennec
- */
-public class RequestLogImpl extends ContextBase implements RequestLog,
-    AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
-
-  public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar + "logback-access.xml";
-
-  AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
-  FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
-  String filename;
-  boolean started = false;
-
-  public RequestLogImpl() {
-    putObject(CoreConstants.EVALUATOR_MAP, new HashMap());
-  }
-
-  public void log(Request jettyRequest, Response jettyResponse) {
-    JettyServerAdapter adapter = new JettyServerAdapter(jettyRequest, jettyResponse);
-    IAccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse, adapter);
-    if (getFilterChainDecision(accessEvent) == FilterReply.DENY) {
-      return;
-    }
-    aai.appendLoopOnAppenders(accessEvent);
-  }
-
-  public void start() {
-    if (filename == null) {
-      String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
-
-      filename = jettyHomeProperty + File.separatorChar + DEFAULT_CONFIG_FILE;
-      getStatusManager().add(
-          new WarnStatus("filename property not set. Assuming [" + filename + "]", this));
-
-    }
-
-    try {
-      File configFile = new File(filename);
-      if (configFile.exists()) {
-        JoranConfigurator jc = new JoranConfigurator();
-        jc.setContext(this);
-        jc.doConfigure(filename);
-
-      } else {
-        getStatusManager().add(new ErrorStatus("[" + filename + "] does not exist", this));
-      }
-
-      if (getName() == null) {
-        setName("LogbackRequestLog");
-      }
-      RequestLogRegistry.register(this);
-      getStatusManager().add(
-          new InfoStatus("RequestLog added to RequestLogRegistry with name: " + getName(), this));
-
-      started = true;
-
-    } catch (JoranException e) {
-      // errors have been registered as status messages
-    }
-  }
-
-  public void stop() {
-    aai.detachAndStopAllAppenders();
-    started = false;
-  }
-
-  public boolean isRunning() {
-    return started;
-  }
-
-  public void setFileName(String filename) {
-    this.filename = filename;
-  }
-
-  public boolean isStarted() {
-    return started;
-  }
-
-  public boolean isStarting() {
-    return false;
-  }
-
-  public boolean isStopping() {
-    return false;
-  }
-
-  public boolean isStopped() {
-    return !started;
-  }
-
-  public boolean isFailed() {
-    return false;
-  }
-
-  public void addLifeCycleListener(Listener listener) {
-    //no support for listeners yet
-  }
-
-  public void removeLifeCycleListener(Listener listener) {
-    //no support for listeners yet
-  }
-
-  public void addAppender(Appender<IAccessEvent> newAppender) {
-    aai.addAppender(newAppender);
-  }
-
-  public Iterator<Appender<IAccessEvent>> iteratorForAppenders() {
-    return aai.iteratorForAppenders();
-  }
-
-  public Appender<IAccessEvent> getAppender(String name) {
-    return aai.getAppender(name);
-  }
-
-  public boolean isAttached(Appender<IAccessEvent> appender) {
-    return aai.isAttached(appender);
-  }
-
-  public void detachAndStopAllAppenders() {
-    aai.detachAndStopAllAppenders();
-
-  }
-
-  public boolean detachAppender(Appender<IAccessEvent> appender) {
-    return aai.detachAppender(appender);
-  }
-
-  public boolean detachAppender(String name) {
-    return aai.detachAppender(name);
-  }
-
-  public void addFilter(Filter<IAccessEvent> newFilter) {
-    fai.addFilter(newFilter);
-  }
-
-  public void clearAllFilters() {
-    fai.clearAllFilters();
-  }
-
-  public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
-    return fai.getCopyOfAttachedFiltersList();
-  }
-
-  public FilterReply getFilterChainDecision(IAccessEvent event) {
-    return fai.getFilterChainDecision(event);
-  }
-}
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogRegistry.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogRegistry.java
deleted file mode 100644
index 91d299a..0000000
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogRegistry.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- *   or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package ch.qos.logback.access.jetty.v7;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Sébastien Pennec
- * @author Ceki Gulcu
- * 
- * <p>
- * <strong>Note</strong> that this implementation works with Jetty version 7.x.x.
- * For Jetty 6.x.x implementations, see {@link ch.qos.logback.access.jetty.RequestLogRegistry}.
- */
-public class RequestLogRegistry {
-
-  private static Map<String, RequestLogImpl> requestLogRegistry = new HashMap<String, RequestLogImpl>();
-
-  public static void register(RequestLogImpl requestLogImpl) {
-    requestLogRegistry.put(requestLogImpl.getName(), requestLogImpl);
-  }
-
-  public static RequestLogImpl get(String key) {
-    return requestLogRegistry.get(key);
-  }
-
-}
\ No newline at end of file
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/package.html b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/package.html
deleted file mode 100644
index 2931400..0000000
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/package.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-
-<html> 
-  <head>
-    <title></title>
-  </head>
-  
-  <body>
-    
-    <p>This is logback access' implementation for Jetty version 7 and later.</p>
-
-  </body> 
-</html>
\ No newline at end of file

-----------------------------------------------------------------------

Summary of changes:
 .../qos/logback/access/jetty/RequestLogImpl.java   |   70 ++++--
 .../access/jetty/v7/JettyServerAdapter.java        |   64 -----
 .../logback/access/jetty/v7/RequestLogImpl.java    |  253 --------------------
 .../access/jetty/v7/RequestLogRegistry.java        |   39 ---
 .../ch/qos/logback/access/jetty/v7/package.html    |   13 -
 .../java/ch/qos/logback/core/util/FileUtil.java    |    9 +
 6 files changed, 59 insertions(+), 389 deletions(-)
 delete mode 100644 logback-access/src/main/java/ch/qos/logback/access/jetty/v7/JettyServerAdapter.java
 delete mode 100644 logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
 delete mode 100644 logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogRegistry.java
 delete mode 100644 logback-access/src/main/java/ch/qos/logback/access/jetty/v7/package.html


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list