From b73153c578a48b0c57033188e7b9e9b8e7eb68e5 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Fri, 26 Aug 2022 17:45:48 +0200 Subject: [PATCH] indentation changes Signed-off-by: Ceki Gulcu --- .../logback/access/jetty/RequestLogImpl.java | 117 +++++++++--------- 1 file changed, 61 insertions(+), 56 deletions(-) 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 af3de79116..acb9aa67a9 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 @@ -1,13 +1,13 @@ /** * Logback: the reliable, generic, fast and flexible logging framework. * Copyright (C) 1999-2015, 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) - * + *

+ * 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. */ @@ -54,34 +54,36 @@ *

*

Supported Jetty Versions

*

- * This {@code RequestLogImpl} only supports Jetty 7.0.0 through Jetty 10. - * If you are using Jetty 11 with the new Jakarta Servlets (namespace {@code jakarta.servlet}) - * then you will need a more modern version of {@code logback-access}. + * This {@code RequestLogImpl} only supports Jetty 7.0.0 through Jetty 10. + * If you are using Jetty 11 with the new Jakarta Servlets (namespace {@code jakarta.servlet}) + * then you will need a more modern version of {@code logback-access}. *

*

Configuring for Jetty 9.4.x through to Jetty 10.0.x

*

- * Jetty 9.4.x and Jetty 10.x use a modern @{code server.setRequestLog(RequestLog)} interface that - * is based on a Server level RequestLog behavior. This means all requests are logged, - * even bad requests, and context-less requests. The internals of the Jetty Request and - * Response objects track the state of the object at the time they are committed (the - * actual state during the application when an action on the network commits the - * request/response exchange). This prevents behaviors from 3rd party libraries - * that change the state of the request / response before the RequestLog gets a chance - * to log the details. This differs from Jetty 9.3.x and - * older in that those versions used a (now deprecated) {@code RequestLogHandler} and - * would never see bad requests, or context-less requests, - * and if a 3rd party library modifies the the response (for example by setting - * {@code response.setStatus(200)} after the response has been initiated on the network) - * this change in status would be logged, instead of the actual status that was sent. + * Jetty 9.4.x and Jetty 10.x use a modern {@code org.eclipse.jetty.server.Server.setRequestLog(RequestLog)} + * interface that is based on a Server level RequestLog behavior. This means all requests are logged, + * even bad requests, and context-less requests. + *

+ *

+ * The internals of the Jetty Request and Response objects track the state of the object at the time + * they are committed (the actual state during the application when an action on the network commits the + * request/response exchange). This prevents behaviors from 3rd party libraries + * that change the state of the request / response before the RequestLog gets a chance + * to log the details. This differs from Jetty 9.3.x and + * older in that those versions used a (now deprecated) {@code RequestLogHandler} and + * would never see bad requests, or context-less requests, + * and if a 3rd party library modifies the the response (for example by setting + * {@code response.setStatus(200)} after the response has been initiated on the network) + * this change in status would be logged, instead of the actual status that was sent. *

*

- * First, you must be using the proper {@code ${jetty.home}} and {@code ${jetty.base}} - * directory split. Configure your {@code ${jetty.base}} with at least the `resources` module - * enabled (so that your configuration can be found). + * First, you must be using the proper {@code ${jetty.home}} and {@code ${jetty.base}} + * directory split. Configure your {@code ${jetty.base}} with at least the `resources` module + * enabled (so that your configuration can be found). *

*

- * Next, create a {@code ${jetty.base}/etc/logback-access-requestlog.xml} file with the following - * content. + * Next, create a {@code ${jetty.base}/etc/logback-access.xml} file with the following + * content. *

*
  *   <?xml version="1.0"?>
@@ -93,23 +95,29 @@
  *         <Set name="resource">logback-access.xml</Set>
  *       </New>
  *     </Set>
- *   </Configure>
- * 
- *

+ * </Configure> + * *

- * Now you'll need a {@code ${jetty.base}/resources/logback-access.xml} configuration file. + * Now you'll need a {@code ${jetty.base}/resources/logback-access.xml} configuration file. *

+ * + *

* By default, {@code RequestLogImpl} looks for a logback configuration file called * {@code etc/logback-access.xml}, in the {@code ${jetty.base}} directory, then * the older {@code ${jetty.home}} directory. + *

+ *

* The {@code 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.

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. + * the same: {@link Appender Appenders} and {@link ch.qos.logback.core.Layout layouts} + * are declared the exact same way. However, + * loggers elements are not allowed. + *

+ * + *

It is possible to place the logback configuration file anywhere, as long as it's path is specified. + * Here is another example, with an arbitrary path to the logback-access.xml file. *

- * + * *

  *   <?xml version="1.0"?>
  *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">
@@ -117,7 +125,7 @@
  *   <Configure id="Server" class="org.eclipse.jetty.server.Server">
  *     <Set name="requestLog">
  *       <New id="LogbackAccess" class="ch.qos.logback.access.jetty.RequestLogImpl">
- *         <Set name="fileName">/path/to/logback-access.xml</Set>
+ *         <Set name="fileName">/arbitrary/path/to/logback-access.xml</Set>
  *       </New>
  *     </Set>
  *   </Configure>
@@ -128,6 +136,7 @@
  * the use of the {@code RequestLogHandler} is the technique available to you.
  * Modify your {@code etc/jetty-requestlog.xml}
  * 

+ * *
  *   <?xml version="1.0"?>
  *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
@@ -146,19 +155,21 @@
  *     </Ref>
  *   </Configure>
  * 
- *

- * By default, RequestLogImpl looks for a logback configuration file called + * + *

By default, RequestLogImpl looks for a logback configuration file called * logback-access.xml, in the same folder where jetty.xml is located, that is * etc/logback-access.xml. The logback-access.xml file is slightly * different from 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. + *

+ * *

* 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. *

- * + * *

  *   <?xml version="1.0"?>
  *   <!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
@@ -179,11 +190,10 @@
  *     </Ref>
  *   </Configure>
  * 
- *

*

- * Here is a sample logback-access.xml file that can be used right away: + * Next is a sample logback-access.xml file printing access events on the console. *

- * + * *

  *    <configuration>
  *      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
@@ -195,11 +205,10 @@
  *      <appender-ref ref="STDOUT" />
  *    </configuration>
  * 
- *

*

- * Another configuration file, using SMTPAppender, could be: + * Here is another configuration file, using SMTPAppender: *

- * + * *

  *    <configuration>
  *      <appender name="SMTP" class="ch.qos.logback.access.net.SMTPAppender">
@@ -217,15 +226,16 @@
  *
  * @author Ceki Gülcü
  * @author Sébastien Pennec
+ * @author Joakim Erdfelt
  */
-public class RequestLogImpl extends ContextBase implements org.eclipse.jetty.util.component.LifeCycle, RequestLog,
-        AppenderAttachable, FilterAttachable {
+public class RequestLogImpl extends ContextBase implements org.eclipse.jetty.util.component.LifeCycle, RequestLog, AppenderAttachable, FilterAttachable {
 
     public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar + "logback-access.xml";
 
     enum State {
         FAILED, STOPPED, STARTING, STARTED, STOPPING
     }
+
     State state = State.STOPPED;
 
     AppenderAttachableImpl aai = new AppenderAttachableImpl();
@@ -242,9 +252,7 @@ public RequestLogImpl() {
 
         // plumb the depths of Jetty and the environment ...
         if (EnvUtil.isClassAvailable(this.getClass(), "jakarta.servlet.http.HttpServlet")) {
-            throw new RuntimeException("The new jakarta.servlet classes are not supported by this " +
-                "version of logback-access (check for a newer version of logback-access that " +
-                "does support it)");
+            throw new RuntimeException("The new jakarta.servlet classes are not supported by this " + "version of logback-access (check for a newer version of logback-access that " + "does support it)");
         }
 
         // look for modern approach to RequestLog
@@ -286,7 +294,7 @@ public void start() {
                 StatusPrinter.print(getStatusManager());
             }
             state = State.STARTED;
-        } catch(Throwable t) {
+        } catch (Throwable t) {
             t.printStackTrace();
             state = State.FAILED;
         }
@@ -305,8 +313,7 @@ protected URL getConfigurationFileURL() {
         if (fileName != null) {
             addInfo("Will use configuration file [" + fileName + "]");
             File file = new File(fileName);
-            if (!file.exists())
-                return null;
+            if (!file.exists()) return null;
             return FileUtil.fileToURL(file);
         }
         if (resource != null) {
@@ -322,7 +329,7 @@ protected URL getConfigurationFileURL() {
         }
 
         File file = new File(defaultConfigFile);
-        if(!file.exists()) {
+        if (!file.exists()) {
             // Then use ${jetty.home} (not supported in Jetty 10+)
             String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
             if (!OptionHelper.isEmpty(jettyHomeProperty)) {
@@ -334,8 +341,7 @@ protected URL getConfigurationFileURL() {
 
         file = new File(defaultConfigFile);
         addInfo("Assuming default configuration file [" + defaultConfigFile + "]");
-        if (!file.exists())
-            return null;
+        if (!file.exists()) return null;
         return FileUtil.fileToURL(file);
     }
 
@@ -397,7 +403,6 @@ public boolean isFailed() {
     }
 
 
-
     public boolean isQuiet() {
         return quiet;
     }