[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v_0.9.30-4-g3e93216
added by portage for gitosis-gentoo
git-noreply at pixie.qos.ch
Tue Sep 27 11:10:30 CEST 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 3e9321697098752bbef50544f39ade7cc68e98a2 (commit)
from 6534cfcc93d86c742aec1bdbe5f1b8844e6bd988 (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=3e9321697098752bbef50544f39ade7cc68e98a2
http://github.com/ceki/logback/commit/3e9321697098752bbef50544f39ade7cc68e98a2
commit 3e9321697098752bbef50544f39ade7cc68e98a2
Author: Ceki Gulcu <ceki at qos.ch>
Date: Tue Sep 27 09:22:15 2011 +0200
minro refactoring, cosmetic changes
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 2c0a06a..9071b03 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
@@ -17,7 +17,6 @@ import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import ch.qos.logback.core.util.StatusPrinter;
import org.eclipse.jetty.server.Request;
@@ -39,10 +38,8 @@ import ch.qos.logback.core.spi.FilterAttachable;
import ch.qos.logback.core.spi.FilterAttachableImpl;
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.WarnStatus;
import ch.qos.logback.core.util.OptionHelper;
-import org.eclipse.jetty.util.component.LifeCycle;
/**
* This class is logback's implementation of jetty's RequestLog interface. <p>
@@ -51,15 +48,15 @@ import org.eclipse.jetty.util.component.LifeCycle;
* 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>:
- *
+ * <p/>
* <pre>
- * <Ref id="requestLog">
- * <Set name="requestLog">
+ * <Ref id="requestLog">
+ * <Set name="requestLog">
* <New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl"></New>
- * </Set>
+ * </Set>
* </Ref>
* </pre>
- *
+ * <p/>
* 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
@@ -68,34 +65,34 @@ import org.eclipse.jetty.util.component.LifeCycle;
* 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.
- *
+ * <p/>
* <pre>
- * <Ref id="requestLog">
- * <Set name="requestLog">
+ * <Ref id="requestLog">
+ * <Set name="requestLog">
* <New id="requestLogImpl" class="ch.qos.logback.access.jetty.RequestLogImpl"></New>
* <Set name="fileName">path/to/logback.xml</Set>
- * </Set>
+ * </Set>
* </Ref>
* </pre>
- *
+ * <p/>
* <p> Here is a sample logback-access.xml file that can be used right away:
- *
+ * <p/>
* <pre>
- * <configuration>
- * <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- * <layout class="ch.qos.logback.access.PatternLayout">
+ * <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" />
+ * </layout>
+ * </appender>
+ *
+ * <appender-ref ref="STDOUT" />
* </configuration>
* </pre>
- *
+ * <p/>
* <p> Another configuration file, using SMTPAppender, could be:
- *
+ * <p/>
* <pre>
- * <configuration>
+ * <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" />
@@ -105,23 +102,24 @@ import org.eclipse.jetty.util.component.LifeCycle;
* <param name="Subject" value="Last Event: %statusCode %requestURL" />
* <param name="To" value="server_admin at domain.org" />
* </appender>
- * <appender-ref ref="SMTP" />
+ * <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> {
+ AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar
- + "logback-access.xml";
+ + "logback-access.xml";
AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
FilterAttachableImpl<IAccessEvent> fai = new FilterAttachableImpl<IAccessEvent>();
- String filename;
+ String fileName;
boolean started = false;
+ boolean quiet = false;
public RequestLogImpl() {
putObject(CoreConstants.EVALUATOR_MAP, new HashMap());
@@ -129,9 +127,9 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
public void log(Request jettyRequest, Response jettyResponse) {
JettyServerAdapter adapter = new JettyServerAdapter(jettyRequest,
- jettyResponse);
+ jettyResponse);
IAccessEvent accessEvent = new AccessEvent(jettyRequest, jettyResponse,
- adapter);
+ adapter);
if (getFilterChainDecision(accessEvent) == FilterReply.DENY) {
return;
}
@@ -139,37 +137,40 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
}
public void start() {
- Properties p = System.getProperties();
- System.out.println(p);
- if (filename == null) {
+ 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 {
+ if (OptionHelper.isEmpty(jettyHomeProperty)) {
getStatusManager().add(
- new ErrorStatus("[" + filename + "] does not exist", this));
+ 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);
+ } else {
+ getStatusManager().add(
+ new ErrorStatus("Could not find logback-access configuration file [" + fileName + "]", this));
+ }
+ if (!isQuiet()) {
+ StatusPrinter.print(getStatusManager());
+ }
+ started = true;
+ }
+ private void runJoranOnFile(File configFile) {
+ try {
+ JoranConfigurator jc = new JoranConfigurator();
+ jc.setContext(this);
+ jc.doConfigure(configFile);
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
}
@@ -184,8 +185,8 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
return started;
}
- public void setFileName(String filename) {
- this.filename = filename;
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
}
public boolean isStarted() {
@@ -208,6 +209,13 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
return false;
}
+ public boolean isQuiet() {
+ return quiet;
+ }
+
+ public void setQuiet(boolean quiet) {
+ this.quiet = quiet;
+ }
public void addAppender(Appender<IAccessEvent> newAppender) {
aai.addAppender(newAppender);
@@ -249,7 +257,7 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
public List<Filter<IAccessEvent>> getCopyOfAttachedFiltersList() {
return fai.getCopyOfAttachedFiltersList();
}
-
+
public FilterReply getFilterChainDecision(IAccessEvent event) {
return fai.getFilterChainDecision(event);
}
@@ -257,6 +265,7 @@ public class RequestLogImpl extends ContextBase implements RequestLog,
public void addLifeCycleListener(Listener listener) {
// we'll implement this when asked
}
+
public void removeLifeCycleListener(Listener listener) {
// we'll implement this when asked
}
diff --git a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java
index f0dbc45..6eddce3 100644
--- a/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java
+++ b/logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogRegistry.java
@@ -16,6 +16,7 @@ package ch.qos.logback.access.jetty;
import java.util.HashMap;
import java.util.Map;
+// this class is currently not used
public class RequestLogRegistry {
private static Map<String, RequestLogImpl> requestLogRegistry = new HashMap<String, RequestLogImpl>();
-----------------------------------------------------------------------
Summary of changes:
.../qos/logback/access/jetty/RequestLogImpl.java | 125 +++++++++++---------
.../logback/access/jetty/RequestLogRegistry.java | 1 +
2 files changed, 68 insertions(+), 58 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
More information about the logback-dev
mailing list