Skip to content

Commit b73153c

Browse files
committed
indentation changes
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent 5175596 commit b73153c

File tree

1 file changed

+61
-56
lines changed

1 file changed

+61
-56
lines changed

logback-access/src/main/java/ch/qos/logback/access/jetty/RequestLogImpl.java

+61-56
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
22
* Logback: the reliable, generic, fast and flexible logging framework.
33
* Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4-
*
4+
* <p>
55
* This program and the accompanying materials are dual-licensed under
66
* either the terms of the Eclipse Public License v1.0 as published by
77
* the Eclipse Foundation
8-
*
9-
* or (per the licensee's choosing)
10-
*
8+
* <p>
9+
* or (per the licensee's choosing)
10+
* <p>
1111
* under the terms of the GNU Lesser General Public License version 2.1
1212
* as published by the Free Software Foundation.
1313
*/
@@ -54,34 +54,36 @@
5454
* </p>
5555
* <h2>Supported Jetty Versions</h2>
5656
* <p>
57-
* This {@code RequestLogImpl} only supports Jetty 7.0.0 through Jetty 10.
58-
* If you are using Jetty 11 with the new Jakarta Servlets (namespace {@code jakarta.servlet})
59-
* then you will need a more modern version of {@code logback-access}.
57+
* This {@code RequestLogImpl} only supports Jetty 7.0.0 through Jetty 10.
58+
* If you are using Jetty 11 with the new Jakarta Servlets (namespace {@code jakarta.servlet})
59+
* then you will need a more modern version of {@code logback-access}.
6060
* </p>
6161
* <h2>Configuring for Jetty 9.4.x through to Jetty 10.0.x</h2>
6262
* <p>
63-
* Jetty 9.4.x and Jetty 10.x use a modern @{code server.setRequestLog(RequestLog)} interface that
64-
* is based on a Server level RequestLog behavior. This means all requests are logged,
65-
* even bad requests, and context-less requests. The internals of the Jetty Request and
66-
* Response objects track the state of the object at the time they are committed (the
67-
* actual state during the application when an action on the network commits the
68-
* request/response exchange). This prevents behaviors from 3rd party libraries
69-
* that change the state of the request / response before the RequestLog gets a chance
70-
* to log the details. This differs from Jetty 9.3.x and
71-
* older in that those versions used a (now deprecated) {@code RequestLogHandler} and
72-
* would never see bad requests, or context-less requests,
73-
* and if a 3rd party library modifies the the response (for example by setting
74-
* {@code response.setStatus(200)} after the response has been initiated on the network)
75-
* this change in status would be logged, instead of the actual status that was sent.
63+
* Jetty 9.4.x and Jetty 10.x use a modern {@code org.eclipse.jetty.server.Server.setRequestLog(RequestLog)}
64+
* interface that is based on a Server level RequestLog behavior. This means all requests are logged,
65+
* even bad requests, and context-less requests.
66+
* </p>
67+
* <p>
68+
* The internals of the Jetty Request and Response objects track the state of the object at the time
69+
* they are committed (the actual state during the application when an action on the network commits the
70+
* request/response exchange). This prevents behaviors from 3rd party libraries
71+
* that change the state of the request / response before the RequestLog gets a chance
72+
* to log the details. This differs from Jetty 9.3.x and
73+
* older in that those versions used a (now deprecated) {@code RequestLogHandler} and
74+
* would never see bad requests, or context-less requests,
75+
* and if a 3rd party library modifies the the response (for example by setting
76+
* {@code response.setStatus(200)} after the response has been initiated on the network)
77+
* this change in status would be logged, instead of the actual status that was sent.
7678
* </p>
7779
* <p>
78-
* First, you must be using the proper {@code ${jetty.home}} and {@code ${jetty.base}}
79-
* directory split. Configure your {@code ${jetty.base}} with at least the `resources` module
80-
* enabled (so that your configuration can be found).
80+
* First, you must be using the proper {@code ${jetty.home}} and {@code ${jetty.base}}
81+
* directory split. Configure your {@code ${jetty.base}} with at least the `resources` module
82+
* enabled (so that your configuration can be found).
8183
* </p>
8284
* <p>
83-
* Next, create a {@code ${jetty.base}/etc/logback-access-requestlog.xml} file with the following
84-
* content.
85+
* Next, create a {@code ${jetty.base}/etc/logback-access.xml} file with the following
86+
* content.
8587
* </p>
8688
* <pre>
8789
* &lt;?xml version="1.0"?&gt;
@@ -93,31 +95,37 @@
9395
* &lt;Set name="resource"&gt;logback-access.xml&lt;/Set&gt;
9496
* &lt;/New&gt;
9597
* &lt;/Set&gt;
96-
* &lt;/Configure&gt;
97-
* </pre>
98-
* <p/>
98+
* &lt;/Configure&gt;</pre>
99+
*
99100
* <p>
100-
* Now you'll need a {@code ${jetty.base}/resources/logback-access.xml} configuration file.
101+
* Now you'll need a {@code ${jetty.base}/resources/logback-access.xml} configuration file.
101102
* </p>
103+
*
104+
* <p>
102105
* By default, {@code RequestLogImpl} looks for a logback configuration file called
103106
* {@code etc/logback-access.xml}, in the {@code ${jetty.base}} directory, then
104107
* the older {@code ${jetty.home}} directory.
108+
* </p>
109+
* <p>
105110
* The {@code logback-access.xml} file is slightly
106111
* different than the usual logback classic configuration file. Most of it is
107-
* the same: Appenders and Layouts are declared the exact same way. However,
108-
* loggers elements are not allowed. <p> It is possible to put the logback
109-
* configuration file anywhere, as long as it's path is specified. Here is
110-
* another example, with a path to the logback-access.xml file.
112+
* the same: {@link Appender Appenders} and {@link ch.qos.logback.core.Layout layouts}
113+
* are declared the exact same way. However,
114+
* loggers elements are not allowed.
115+
* </p>
116+
*
117+
* <p> It is possible to place the logback configuration file anywhere, as long as it's path is specified.
118+
* Here is another example, with an arbitrary path to the logback-access.xml file.
111119
* <p/>
112-
*
120+
*
113121
* <pre>
114122
* &lt;?xml version="1.0"?&gt;
115123
* &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd"&gt;
116124
*
117125
* &lt;Configure id="Server" class="org.eclipse.jetty.server.Server"&gt;
118126
* &lt;Set name="requestLog"&gt;
119127
* &lt;New id="LogbackAccess" class="ch.qos.logback.access.jetty.RequestLogImpl"&gt;
120-
* &lt;Set name="fileName"&gt;/path/to/logback-access.xml&lt;/Set&gt;
128+
* &lt;Set name="fileName"&gt;/arbitrary/path/to/logback-access.xml&lt;/Set&gt;
121129
* &lt;/New&gt;
122130
* &lt;/Set&gt;
123131
* &lt;/Configure&gt;
@@ -128,6 +136,7 @@
128136
* the use of the {@code RequestLogHandler} is the technique available to you.
129137
* Modify your {@code etc/jetty-requestlog.xml}
130138
* </p>
139+
*
131140
* <pre>
132141
* &lt;?xml version="1.0"?&gt;
133142
* &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"&gt;
@@ -146,19 +155,21 @@
146155
* &lt;/Ref&gt;
147156
* &lt;/Configure&gt;
148157
* </pre>
149-
* <p/>
150-
* By default, RequestLogImpl looks for a logback configuration file called
158+
*
159+
* <p>By default, RequestLogImpl looks for a logback configuration file called
151160
* logback-access.xml, in the same folder where jetty.xml is located, that is
152161
* <em>etc/logback-access.xml</em>. The logback-access.xml file is slightly
153162
* different from the usual logback classic configuration file. Most of it is
154163
* the same: Appenders and Layouts are declared the exact same way. However,
155164
* loggers elements are not allowed.
165+
* </p>
166+
*
156167
* <p>
157168
* It is possible to put the logback configuration file anywhere, as long as
158169
* it's path is specified. Here is another example, with a path to the
159170
* logback-access.xml file.
160171
* <p/>
161-
*
172+
*
162173
* <pre>
163174
* &lt;?xml version="1.0"?&gt;
164175
* &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd"&gt;
@@ -179,11 +190,10 @@
179190
* &lt;/Ref&gt;
180191
* &lt;/Configure&gt;
181192
* </pre>
182-
* <p/>
183193
* <p>
184-
* Here is a sample logback-access.xml file that can be used right away:
194+
* Next is a sample logback-access.xml file printing access events on the console.
185195
* <p/>
186-
*
196+
*
187197
* <pre>
188198
* &lt;configuration&gt;
189199
* &lt;appender name=&quot;STDOUT&quot; class=&quot;ch.qos.logback.core.ConsoleAppender&quot;&gt;
@@ -195,11 +205,10 @@
195205
* &lt;appender-ref ref=&quot;STDOUT&quot; /&gt;
196206
* &lt;/configuration&gt;
197207
* </pre>
198-
* <p/>
199208
* <p>
200-
* Another configuration file, using SMTPAppender, could be:
209+
* Here is another configuration file, using SMTPAppender:
201210
* <p/>
202-
*
211+
*
203212
* <pre>
204213
* &lt;configuration&gt;
205214
* &lt;appender name=&quot;SMTP&quot; class=&quot;ch.qos.logback.access.net.SMTPAppender&quot;&gt;
@@ -217,15 +226,16 @@
217226
*
218227
* @author Ceki G&uuml;lc&uuml;
219228
* @author S&eacute;bastien Pennec
229+
* @author Joakim Erdfelt
220230
*/
221-
public class RequestLogImpl extends ContextBase implements org.eclipse.jetty.util.component.LifeCycle, RequestLog,
222-
AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
231+
public class RequestLogImpl extends ContextBase implements org.eclipse.jetty.util.component.LifeCycle, RequestLog, AppenderAttachable<IAccessEvent>, FilterAttachable<IAccessEvent> {
223232

224233
public final static String DEFAULT_CONFIG_FILE = "etc" + File.separatorChar + "logback-access.xml";
225234

226235
enum State {
227236
FAILED, STOPPED, STARTING, STARTED, STOPPING
228237
}
238+
229239
State state = State.STOPPED;
230240

231241
AppenderAttachableImpl<IAccessEvent> aai = new AppenderAttachableImpl<IAccessEvent>();
@@ -242,9 +252,7 @@ public RequestLogImpl() {
242252

243253
// plumb the depths of Jetty and the environment ...
244254
if (EnvUtil.isClassAvailable(this.getClass(), "jakarta.servlet.http.HttpServlet")) {
245-
throw new RuntimeException("The new jakarta.servlet classes are not supported by this " +
246-
"version of logback-access (check for a newer version of logback-access that " +
247-
"does support it)");
255+
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)");
248256
}
249257

250258
// look for modern approach to RequestLog
@@ -286,7 +294,7 @@ public void start() {
286294
StatusPrinter.print(getStatusManager());
287295
}
288296
state = State.STARTED;
289-
} catch(Throwable t) {
297+
} catch (Throwable t) {
290298
t.printStackTrace();
291299
state = State.FAILED;
292300
}
@@ -305,8 +313,7 @@ protected URL getConfigurationFileURL() {
305313
if (fileName != null) {
306314
addInfo("Will use configuration file [" + fileName + "]");
307315
File file = new File(fileName);
308-
if (!file.exists())
309-
return null;
316+
if (!file.exists()) return null;
310317
return FileUtil.fileToURL(file);
311318
}
312319
if (resource != null) {
@@ -322,7 +329,7 @@ protected URL getConfigurationFileURL() {
322329
}
323330

324331
File file = new File(defaultConfigFile);
325-
if(!file.exists()) {
332+
if (!file.exists()) {
326333
// Then use ${jetty.home} (not supported in Jetty 10+)
327334
String jettyHomeProperty = OptionHelper.getSystemProperty("jetty.home");
328335
if (!OptionHelper.isEmpty(jettyHomeProperty)) {
@@ -334,8 +341,7 @@ protected URL getConfigurationFileURL() {
334341

335342
file = new File(defaultConfigFile);
336343
addInfo("Assuming default configuration file [" + defaultConfigFile + "]");
337-
if (!file.exists())
338-
return null;
344+
if (!file.exists()) return null;
339345
return FileUtil.fileToURL(file);
340346
}
341347

@@ -397,7 +403,6 @@ public boolean isFailed() {
397403
}
398404

399405

400-
401406
public boolean isQuiet() {
402407
return quiet;
403408
}

0 commit comments

Comments
 (0)