[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-59-g176a1a7
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Wed Mar 3 23:31:28 CET 2010
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 176a1a7219de866a69604d8a8e81f8d759858d5e (commit)
via 9442a2d5a9fc9e938bee8f4b50d427016b77ec38 (commit)
from fc91f4117cfaacbd6deac9fb319a6abe07b45115 (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=176a1a7219de866a69604d8a8e81f8d759858d5e
http://github.com/ceki/logback/commit/176a1a7219de866a69604d8a8e81f8d759858d5e
commit 176a1a7219de866a69604d8a8e81f8d759858d5e
Merge: fc91f41 9442a2d
Author: Ceki Gulcu <ceki at qos.ch>
Date: Wed Mar 3 23:29:56 2010 +0100
Merge branch 'master' of git://github.com/spennec/logback
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=9442a2d5a9fc9e938bee8f4b50d427016b77ec38
http://github.com/ceki/logback/commit/9442a2d5a9fc9e938bee8f4b50d427016b77ec38
commit 9442a2d5a9fc9e938bee8f4b50d427016b77ec38
Author: Sebastien Pennec <sebastien at qos.ch>
Date: Wed Mar 3 22:38:47 2010 +0100
Adding Jetty 7 support
diff --git a/logback-access/pom.xml b/logback-access/pom.xml
index ffb1d14..4c26e9b 100644
--- a/logback-access/pom.xml
+++ b/logback-access/pom.xml
@@ -63,6 +63,13 @@
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <scope>compile</scope>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
<scope>compile</scope>
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
new file mode 100644
index 0000000..eb53108
--- /dev/null
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/JettyServerAdapter.java
@@ -0,0 +1,64 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, 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
new file mode 100644
index 0000000..35bd8ce
--- /dev/null
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogImpl.java
@@ -0,0 +1,256 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, 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.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<AccessEvent>, FilterAttachable<AccessEvent> {
+
+ public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar + "logback-access.xml";
+
+ AppenderAttachableImpl<AccessEvent> aai = new AppenderAttachableImpl<AccessEvent>();
+ FilterAttachableImpl<AccessEvent> fai = new FilterAttachableImpl<AccessEvent>();
+ 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);
+ AccessEvent 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<AccessEvent> newAppender) {
+ aai.addAppender(newAppender);
+ }
+
+ public Iterator<Appender<AccessEvent>> iteratorForAppenders() {
+ return aai.iteratorForAppenders();
+ }
+
+ public Appender<AccessEvent> getAppender(String name) {
+ return aai.getAppender(name);
+ }
+
+ public boolean isAttached(Appender<AccessEvent> appender) {
+ return aai.isAttached(appender);
+ }
+
+ public void detachAndStopAllAppenders() {
+ aai.detachAndStopAllAppenders();
+
+ }
+
+ public boolean detachAppender(Appender<AccessEvent> appender) {
+ return aai.detachAppender(appender);
+ }
+
+ public boolean detachAppender(String name) {
+ return aai.detachAppender(name);
+ }
+
+ public void addFilter(Filter<AccessEvent> newFilter) {
+ fai.addFilter(newFilter);
+ }
+
+ public void clearAllFilters() {
+ fai.clearAllFilters();
+ }
+
+ public List<Filter<AccessEvent>> getCopyOfAttachedFiltersList() {
+ return fai.getCopyOfAttachedFiltersList();
+ }
+
+ public FilterReply getFilterChainDecision(AccessEvent event) {
+ return fai.getFilterChainDecision(event);
+ }
+
+ public Filter getFirstFilter() {
+ return fai.getFirstFilter();
+ }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..2e3878d
--- /dev/null
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/RequestLogRegistry.java
@@ -0,0 +1,39 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * Copyright (C) 1999-2009, 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
new file mode 100644
index 0000000..2931400
--- /dev/null
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/v7/package.html
@@ -0,0 +1,13 @@
+<!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
diff --git a/pom.xml b/pom.xml
index 2af4ff3..c2ff239 100755
--- a/pom.xml
+++ b/pom.xml
@@ -104,6 +104,11 @@
<version>6.1.1</version>
</dependency>
<dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>7.0.1.v20091125</version>
+ </dependency>
+ <dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
<version>6.1.1</version>
-----------------------------------------------------------------------
Summary of changes:
logback-access/pom.xml | 7 ++
.../access/jetty/{ => v7}/JettyServerAdapter.java | 26 +++--
.../access/jetty/{ => v7}/RequestLogImpl.java | 112 ++++++++++----------
.../access/jetty/{ => v7}/RequestLogRegistry.java | 18 +++-
.../qos/logback/access/{ => jetty/v7}/package.html | 2 +-
pom.xml | 5 +
6 files changed, 97 insertions(+), 73 deletions(-)
copy logback-access/src/main/java/ch/qos/logback/access/jetty/{ => v7}/JettyServerAdapter.java (76%)
copy logback-access/src/main/java/ch/qos/logback/access/jetty/{ => v7}/RequestLogImpl.java (81%)
copy logback-access/src/main/java/ch/qos/logback/access/jetty/{ => v7}/RequestLogRegistry.java (74%)
copy logback-access/src/main/java/ch/qos/logback/access/{ => jetty/v7}/package.html (58%)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list