Format String | -Description | -
%% | -The percent sign. | -
%{format}a | -- Client IP address of the request. - Valid formats are {server, client, local, remote} - - where server and client are the logical addresses - where local and remote are the physical addresses - | -
%a | -Client IP address of the request. | -
%{c}a | -Underlying peer IP address of the connection. | -
%A | -Local IP-address. | -
%h | -Remote hostname. Will log a dotted-string form of the IP if the Hostname cannot be resolved. | -
%v | -- todo this is now %{server}a - The canonical ServerName of the server serving the request. | -
%B | -Size of response in bytes, excluding HTTP headers. | -
%b | -Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a '-' rather than a 0 when no bytes are sent. | -
%{VARNAME}C | -- The contents of cookie VARNAME in the request sent to the server. Only version 0 cookies are fully supported. - Optional VARNAME parameter, without this parameter %C will log all cookies from the request. - | -
%D | -The time taken to serve the request, in microseconds. | -
%{VARNAME}e | -The contents of the environment variable VARNAME. | -
%f | -Filename. | -
%H | -The request protocol. | -
%{VARNAME}i | -The contents of VARNAME: header line(s) in the request sent to the server. | -
%k | -Number of keepalive requests handled on this connection. - Interesting if KeepAlive is being used, so that, for example, a '1' means the first keepalive request - after the initial one, '2' the second, etc...; otherwise this is always 0 (indicating the initial request). | -
%m | -The request method. | -
%{VARNAME}o | -The contents of VARNAME: header line(s) in the response. | -
%p | -The canonical port of the server serving the request. - todo merge this with below - | -
%{format}p | -The canonical port of the server serving the request, or the server's actual port, or the client's actual port. - Valid formats are canonical, local, or remote. - todo update this documenatation - server, client logical - local, remote physical - | -
%q | -The query string (prepended with a ? if a query string exists, otherwise an empty string). | -
%r | -First line of request. | -
%R | -The handler generating the response (if any). | -
%s | -Response status. | -
%{format}t | -
- The time, in the form given by an optional format, parameter (default format [18/Sep/2011:19:18:28 -0400] where
- the last number indicates the timezone offset from GMT.)
- - The format parameter should be in a format supported by {@link DateCache} - |
-
%T | -The time taken to serve the request, in seconds. | -
%{UNIT}T | -The time taken to serve the request, in a time unit given by UNIT. - Valid units are ms for milliseconds, us for microseconds, and s for seconds. - Using s gives the same result as %T without any format; using us gives the same result as %D. | -
%{d}u | -- Remote user if the request was authenticated. May be bogus if return status (%s) is 401 (unauthorized). - Optional parameter d, with this parameter deferred authentication will also be checked. - | -
%U | -The URL path requested, not including any query string. | -
%X | -
- Connection status when response is completed:
- - X = Connection aborted before the response completed. - + = Connection may be kept alive after the response is sent. - - = Connection will be closed after the response is sent.- |
-
%I | -Bytes received. | -
%O | -Bytes sent. | -
%S | -Bytes transferred (received and sent). This is the combination of %I and %O. | -
%{VARNAME}^ti | -The contents of VARNAME: trailer line(s) in the request sent to the server. | -
%{VARNAME}^to | -The contents of VARNAME: trailer line(s) in the response sent from the server. | -
+ * The terms server, client, local and remote are used to refer to the different addresses and ports
+ * which can be logged. Server and client refer to the logical addresses which can be modified in the request
+ * headers. Where local and remote refer to the physical addresses which may be a proxy between the
+ * end-user and the server.
+ *
+ *
+ *
Percent codes are specified in the format %MODIFIERS{PARAM}CODE
+ *
+ * MODIFIERS: + * Optional list of comma separated HTTP status codes which may be preceded by a single "!" to indicate + * negation. If the status code is not in the list the literal string "-" will be logged instead of + * the resulting value from the percent code. + * {PARAM}: + * Parameter string which may be optional depending on the percent code used. + * CODE: + * A one or two character code specified by the {@link CustomRequestLog} table of format codes. + *+ * + *
Format String | + *Description | + *
%% | + *The percent sign. | + *
%{format}a | + *
+ * Address or Hostname. Valid formats are {server, client, local, remote}
+ * Optional format parameter which will be server by default.
+ * + * Where server and client are the logical addresses which can be modified in the request headers, while local and + * remote are the physical addresses so may be a proxy between the end-user and the server. + * |
+ *
%{format}p | + *
+ * Port. Valid formats are {server, client, local, remote}
+ * Optional format parameter which will be server by default.
+ * + * Where server and client are the logical ports which can be modified in the request headers, while local and + * remote are the physical ports so may be to a proxy between the end-user and the server. + * |
+ *
%{clf}I | + *+ * Size of request in bytes, excluding HTTP headers. + * Optional parameter with value of clf to use CLF format, i.e. a '-' rather than a 0 when no bytes are sent. + * | + *
%{clf}O | + *+ * Size of response in bytes, excluding HTTP headers. + * Optional parameter with value of clf to use CLF format, i.e. a '-' rather than a 0 when no bytes are sent. + * | + *
%{clf}S | + *+ * Bytes transferred (received and sent). This is the combination of %I and %O. + * Optional parameter with value of clf to use CLF format, i.e. a '-' rather than a 0 when no bytes are sent. + * | + *
%{VARNAME}C | + *+ * The contents of cookie VARNAME in the request sent to the server. Only version 0 cookies are fully supported. + * Optional VARNAME parameter, without this parameter %C will log all cookies from the request. + * | + *
%D | + *The time taken to serve the request, in microseconds. | + *
%{VARNAME}e | + *The contents of the environment variable VARNAME. | + *
%f | + *Filename. | + *
%H | + *The request protocol. | + *
%{VARNAME}i | + *The contents of VARNAME: header line(s) in the request sent to the server. | + *
%k | + *Number of keepalive requests handled on this connection. + * Interesting if KeepAlive is being used, so that, for example, a '1' means the first keepalive request + * after the initial one, '2' the second, etc...; otherwise this is always 0 (indicating the initial request). | + *
%m | + *The request method. | + *
%{VARNAME}o | + *The contents of VARNAME: header line(s) in the response. | + *
%q | + *The query string (prepended with a ? if a query string exists, otherwise an empty string). | + *
%r | + *First line of request. | + *
%R | + *The handler generating the response (if any). | + *
%s | + *Response status. | + *
%{format}t | + *
+ * The time, in the form given by an optional format, parameter (default format [18/Sep/2011:19:18:28 -0400] where
+ * the last number indicates the timezone offset from GMT.)
+ * + * The format parameter should be in a format supported by {@link DateCache} + * |
+ *
%T | + *The time taken to serve the request, in seconds. | + *
%{UNIT}T | + *The time taken to serve the request, in a time unit given by UNIT. + * Valid units are ms for milliseconds, us for microseconds, and s for seconds. + * Using s gives the same result as %T without any format; using us gives the same result as %D. | + *
%{d}u | + *+ * Remote user if the request was authenticated. May be bogus if return status (%s) is 401 (unauthorized). + * Optional parameter d, with this parameter deferred authentication will also be checked. + * | + *
%U | + *The URL path requested, not including any query string. | + *
%X | + *
+ * Connection status when response is completed:
+ * + * X = Connection aborted before the response completed. + * + = Connection may be kept alive after the response is sent. + * - = Connection will be closed after the response is sent.+ * |
+ *
%{VARNAME}^ti | + *The contents of VARNAME: trailer line(s) in the request sent to the server. | + *
%{VARNAME}^to | + *The contents of VARNAME: trailer line(s) in the response sent from the server. | + *
(?:(?:ti)|(?:to)|[a-zA-Z%]))|(?[^%]+))(?.*)");
List tokens = new ArrayList<>();
String remaining = formatString;
- while(remaining.length()>0)
+ while (remaining.length() > 0)
{
Matcher m = PATTERN.matcher(remaining);
if (m.matches())
@@ -542,6 +555,7 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
this.literal = null;
}
+
public Token(String literal)
{
this.code = null;
@@ -554,17 +568,16 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
public boolean isLiteralString()
{
- return(literal != null);
+ return (literal != null);
}
public boolean isPercentCode()
{
- return(code != null);
+ return (code != null);
}
}
-
private MethodHandle updateLogHandle(MethodHandle logHandle, MethodHandle append, String literal)
{
return foldArguments(logHandle, dropArguments(dropArguments(append.bindTo(literal), 1, Request.class), 2, Response.class));
@@ -577,11 +590,11 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
String responseCode = Integer.toString(response.getStatus());
if (negated)
{
- return(!modifiers.contains(responseCode));
+ return (!modifiers.contains(responseCode));
}
else
{
- return(modifiers.contains(responseCode));
+ return (modifiers.contains(responseCode));
}
}
@@ -602,6 +615,9 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
case "a":
{
+ if (arg == null || arg.isEmpty())
+ arg = "server";
+
String method;
switch (arg)
{
@@ -629,23 +645,35 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
break;
}
- case "h":
+ case "p":
{
- String method = "logRemoteHostName";
- specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
- break;
- }
+ if (arg == null || arg.isEmpty())
+ arg = "server";
- case "B":
- {
- String method = "logResponseSize";
- specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
- break;
- }
+ String method;
+ switch (arg)
+ {
+
+ case "server":
+ method = "logServerPort";
+ break;
+
+ case "client":
+ method = "logClientPort";
+ break;
+
+ case "local":
+ method = "logLocalPort";
+ break;
+
+ case "remote":
+ method = "logRemotePort";
+ break;
+
+ default:
+ throw new IllegalArgumentException("Invalid arg for %p");
+ }
- case "b":
- {
- String method = "logResponseSizeCLF";
specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
break;
}
@@ -656,9 +684,7 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
if (arg == null || arg.isEmpty())
method = "logBytesReceived";
else if (arg.equals("CLF"))
- {
method = "logBytesReceivedCLF";
- }
else
throw new IllegalArgumentException("Invalid argument for %I");
@@ -672,11 +698,23 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
if (arg == null || arg.isEmpty())
method = "logBytesSent";
else if (arg.equals("CLF"))
- {
method = "logBytesSentCLF";
- }
else
- throw new IllegalArgumentException("Invalid argument for %I");
+ throw new IllegalArgumentException("Invalid argument for %O");
+
+ specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
+ break;
+ }
+
+ case "S":
+ {
+ String method;
+ if (arg == null || arg.isEmpty())
+ method = "logBytesTransferred";
+ else if (arg.equals("CLF"))
+ method = "logBytesTransferredCLF";
+ else
+ throw new IllegalArgumentException("Invalid argument for %S");
specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
break;
@@ -767,36 +805,6 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
break;
}
- case "p":
- {
- String method;
- switch (arg)
- {
-
- case "server":
- method = "logServerPort";
- break;
-
- case "client":
- method = "logClientPort";
- break;
-
- case "local":
- method = "logLocalPort";
- break;
-
- case "remote":
- method = "logRemotePort";
- break;
-
- default:
- throw new IllegalArgumentException("Invalid arg for %p");
- }
-
- specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
- break;
- }
-
case "q":
{
String method = "logQueryString";
@@ -829,9 +837,9 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
{
DateCache logDateCache;
if (arg == null || arg.isEmpty())
- logDateCache = new DateCache(DEFAULT_DATE_FORMAT, _logLocale , _logTimeZone);
+ logDateCache = new DateCache(DEFAULT_DATE_FORMAT, _logLocale, _logTimeZone);
else
- logDateCache = new DateCache(arg, _logLocale , _logTimeZone);
+ logDateCache = new DateCache(arg, _logLocale, _logTimeZone);
String method = "logRequestTime";
MethodType logTypeDateCache = methodType(Void.TYPE, DateCache.class, StringBuilder.class, Request.class, Response.class);
@@ -891,14 +899,6 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
break;
}
- case "S":
- {
- String method = "logBytesTransferred";
- specificHandle = MethodHandles.lookup().findStatic(CustomRequestLog.class, method, logType);
- break;
- }
-
-
case "ti":
{
if (arg == null || arg.isEmpty())
@@ -940,7 +940,6 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
}
-
//-----------------------------------------------------------------------------------//
private static void logNothing(StringBuilder b, Request request, Response response)
@@ -996,7 +995,7 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
private static void logResponseSizeCLF(StringBuilder b, Request request, Response response)
{
long written = response.getHttpChannel().getBytesWritten();
- if (written==0)
+ if (written == 0)
b.append('-');
else
b.append(written);
@@ -1007,17 +1006,47 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
b.append(response.getHttpChannel().getBytesWritten());
}
+ private static void logBytesSentCLF(StringBuilder b, Request request, Response response)
+ {
+ long sent = response.getHttpChannel().getBytesWritten();
+ if (sent == 0)
+ b.append('-');
+ else
+ b.append(sent);
+ }
+
private static void logBytesReceived(StringBuilder b, Request request, Response response)
{
//todo this be content received rather than consumed
b.append(request.getHttpInput().getContentConsumed());
}
+ private static void logBytesReceivedCLF(StringBuilder b, Request request, Response response)
+ {
+ //todo this be content received rather than consumed
+ long received = request.getHttpInput().getContentConsumed();
+ if (received == 0)
+ b.append('-');
+ else
+ b.append(received);
+ }
+
private static void logBytesTransferred(StringBuilder b, Request request, Response response)
{
+ //todo this be content received rather than consumed
b.append(request.getHttpInput().getContentConsumed() + response.getHttpOutput().getWritten());
}
+ private static void logBytesTransferredCLF(StringBuilder b, Request request, Response response)
+ {
+ //todo this be content received rather than consumed
+ long transferred = request.getHttpInput().getContentConsumed() + response.getHttpOutput().getWritten();
+ if (transferred == 0)
+ b.append('-');
+ else
+ b.append(transferred);
+ }
+
private static void logRequestCookie(String arg, StringBuilder b, Request request, Response response)
{
@@ -1059,12 +1088,12 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
private static void logFilename(StringBuilder b, Request request, Response response)
{
UserIdentity.Scope scope = request.getUserIdentityScope();
- if (scope==null || scope.getContextHandler()==null)
+ if (scope == null || scope.getContextHandler() == null)
b.append('-');
else
{
ContextHandler context = scope.getContextHandler();
- int lengthToStrip = scope.getContextPath().length()>1 ? scope.getContextPath().length() : 0;
+ int lengthToStrip = scope.getContextPath().length() > 1 ? scope.getContextPath().length() : 0;
String filename = context.getServletContext().getRealPath(request.getPathInfo().substring(lengthToStrip));
append(b, filename);
}
@@ -1101,7 +1130,7 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
private static void logQueryString(StringBuilder b, Request request, Response response)
{
- append(b, "?"+request.getQueryString());
+ append(b, "?" + request.getQueryString());
}
private static void logRequestFirstLine(StringBuilder b, Request request, Response response)
@@ -1166,7 +1195,7 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog
private static void logConnectionStatus(StringBuilder b, Request request, Response response)
{
- b.append(request.getHttpChannel().isResponseCompleted() ? (request.getHttpChannel().isPersistent() ? '+' : '-') : 'X');
+ b.append(request.getHttpChannel().isResponseCompleted() ? (request.getHttpChannel().isPersistent() ? '+' : '-') : 'X');
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java
index a8a5466543f..6a660fb3dc1 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java
@@ -32,7 +32,8 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
* Format (single log format). This log format can be output by most web
* servers, and almost all web log analysis software can understand these
* formats.
- * @deprecated use {@link CustomRequestLog} given format string {@link CustomRequestLog#NCSA_FORMAT} with a {@link RequestLogWriter}
+ *
+ * @deprecated use {@link CustomRequestLog} given format string {@link CustomRequestLog#EXTENDED_NCSA_FORMAT} with a {@link RequestLogWriter}
*/
@Deprecated
@ManagedObject("NCSA standard format request log")
@@ -40,7 +41,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
{
private final RequestLogWriter _requestLogWriter;
- /* ------------------------------------------------------------ */
/**
* Create request log object with default settings.
*/
@@ -49,7 +49,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
this((String)null);
}
- /* ------------------------------------------------------------ */
/**
* Create request log object with specified output file name.
*
@@ -62,7 +61,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
this(new RequestLogWriter(filename));
}
- /* ------------------------------------------------------------ */
/**
* Create request log object given a RequestLogWriter file name.
*
@@ -76,21 +74,18 @@ public class NCSARequestLog extends AbstractNCSARequestLog
setExtended(true);
}
- /* ------------------------------------------------------------ */
/**
* Set the output file name of the request log.
* The file name may be in the format expected by
* {@link RolloverFileOutputStream}.
*
* @param filename file name of the request log
- *
*/
public void setFilename(String filename)
{
_requestLogWriter.setFilename(filename);
}
- /* ------------------------------------------------------------ */
@Override
public void setLogTimeZone(String tz)
{
@@ -98,7 +93,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
_requestLogWriter.setTimeZone(tz);
}
- /* ------------------------------------------------------------ */
/**
* Retrieve the output file name of the request log.
*
@@ -109,8 +103,7 @@ public class NCSARequestLog extends AbstractNCSARequestLog
{
return _requestLogWriter.getFileName();
}
-
- /* ------------------------------------------------------------ */
+
/**
* Retrieve the file name of the request log with the expanded
* date wildcard if the output is written to the disk using
@@ -123,14 +116,12 @@ public class NCSARequestLog extends AbstractNCSARequestLog
return _requestLogWriter.getDatedFilename();
}
- /* ------------------------------------------------------------ */
@Override
protected boolean isEnabled()
{
return _requestLogWriter.isEnabled();
}
- /* ------------------------------------------------------------ */
/**
* Set the number of days before rotated log files are deleted.
*
@@ -141,7 +132,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
_requestLogWriter.setRetainDays(retainDays);
}
- /* ------------------------------------------------------------ */
/**
* Retrieve the number of days before rotated log files are deleted.
*
@@ -153,7 +143,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
return _requestLogWriter.getRetainDays();
}
- /* ------------------------------------------------------------ */
/**
* Set append to log flag.
*
@@ -165,7 +154,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
_requestLogWriter.setAppend(append);
}
- /* ------------------------------------------------------------ */
/**
* Retrieve append to log flag.
*
@@ -177,19 +165,17 @@ public class NCSARequestLog extends AbstractNCSARequestLog
return _requestLogWriter.isAppend();
}
- /* ------------------------------------------------------------ */
/**
* Set the log file name date format.
- * @see RolloverFileOutputStream#RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)
*
* @param logFileDateFormat format string that is passed to {@link RolloverFileOutputStream}
+ * @see RolloverFileOutputStream#RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)
*/
public void setFilenameDateFormat(String logFileDateFormat)
{
_requestLogWriter.setFilenameDateFormat(logFileDateFormat);
}
- /* ------------------------------------------------------------ */
/**
* Retrieve the file name date format string.
*
@@ -200,14 +186,12 @@ public class NCSARequestLog extends AbstractNCSARequestLog
return _requestLogWriter.getFilenameDateFormat();
}
- /* ------------------------------------------------------------ */
@Override
public void write(String requestEntry) throws IOException
{
_requestLogWriter.write(requestEntry);
}
-
- /* ------------------------------------------------------------ */
+
/**
* Set up request logging and open log file.
*
@@ -219,7 +203,6 @@ public class NCSARequestLog extends AbstractNCSARequestLog
super.doStart();
}
- /* ------------------------------------------------------------ */
/**
* Close the log file and perform cleanup.
*
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLog.java
index 5e59fe01139..4ad0fd64146 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLog.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLog.java
@@ -16,30 +16,34 @@
// ========================================================================
//
-package org.eclipse.jetty.server;
+package org.eclipse.jetty.server;
import java.io.IOException;
import org.eclipse.jetty.server.handler.RequestLogHandler;
-/**
- * A RequestLog
can be attached to a {@link org.eclipse.jetty.server.handler.RequestLogHandler} to enable
+/**
+ * A RequestLog
can be attached to a {@link org.eclipse.jetty.server.handler.RequestLogHandler} to enable
* logging of requests/responses.
+ *
* @see RequestLogHandler#setRequestLog(RequestLog)
* @see Server#setRequestLog(RequestLog)
*/
public interface RequestLog
{
/**
- * @param request The request to log.
+ * @param request The request to log.
* @param response The response to log. Note that for some requests
- * the response instance may not have been fully populated (Eg 400 bad request
- * responses are sent without a servlet response object). Thus for basic
- * log information it is best to consult {@link Response#getCommittedMetaData()}
- * and {@link Response#getHttpChannel()} directly.
+ * the response instance may not have been fully populated (Eg 400 bad request
+ * responses are sent without a servlet response object). Thus for basic
+ * log information it is best to consult {@link Response#getCommittedMetaData()}
+ * and {@link Response#getHttpChannel()} directly.
*/
void log(Request request, Response response);
+ /**
+ * Writes the generated log string to a log sink
+ */
interface Writer
{
void write(String requestEntry) throws IOException;
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLogWriter.java b/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLogWriter.java
index 7015709837d..7f508e6cf95 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLogWriter.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/RequestLogWriter.java
@@ -29,6 +29,9 @@ import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+/**
+ * Writer which outputs pre-formatted request log strings to a file using {@link RolloverFileOutputStream}.
+ */
public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Writer
{
private static final Logger LOG = Log.getLogger(RequestLogWriter.class);
@@ -53,7 +56,7 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
setAppend(true);
setRetainDays(31);
- if(filename != null)
+ if (filename != null)
setFilename(filename);
}
@@ -63,7 +66,6 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
* {@link RolloverFileOutputStream}.
*
* @param filename file name of the request log
- *
*/
public void setFilename(String filename)
{
@@ -86,7 +88,6 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
return _filename;
}
-
/**
* Retrieve the file name of the request log with the expanded
* date wildcard if the output is written to the disk using
@@ -126,7 +127,6 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
return _retainDays;
}
-
/**
* Set append to log flag.
*
@@ -148,19 +148,17 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
return _append;
}
-
/**
* Set the log file name date format.
- * @see RolloverFileOutputStream#RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)
*
* @param logFileDateFormat format string that is passed to {@link RolloverFileOutputStream}
+ * @see RolloverFileOutputStream#RolloverFileOutputStream(String, boolean, int, TimeZone, String, String)
*/
public void setFilenameDateFormat(String logFileDateFormat)
{
_filenameDateFormat = logFileDateFormat;
}
- /* ------------------------------------------------------------ */
/**
* Retrieve the file name date format string.
*
@@ -171,13 +169,12 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
return _filenameDateFormat;
}
- /* ------------------------------------------------------------ */
@Override
public void write(String requestEntry) throws IOException
{
- synchronized(this)
+ synchronized (this)
{
- if (_writer==null)
+ if (_writer == null)
return;
_writer.write(requestEntry);
_writer.write(System.lineSeparator());
@@ -185,18 +182,12 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
}
}
- /* ------------------------------------------------------------ */
- /**
- * Set up request logging and open log file.
- *
- * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStart()
- */
@Override
protected synchronized void doStart() throws Exception
{
if (_filename != null)
{
- _fileOut = new RolloverFileOutputStream(_filename,_append,_retainDays,TimeZone.getTimeZone(getTimeZone()),_filenameDateFormat,null);
+ _fileOut = new RolloverFileOutputStream(_filename, _append, _retainDays, TimeZone.getTimeZone(getTimeZone()), _filenameDateFormat, null);
_closeOut = true;
LOG.info("Opened " + getDatedFilename());
}
@@ -205,7 +196,7 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
_out = _fileOut;
- synchronized(this)
+ synchronized (this)
{
_writer = new OutputStreamWriter(_out);
}
@@ -222,12 +213,6 @@ public class RequestLogWriter extends AbstractLifeCycle implements RequestLog.Wr
return _timeZone;
}
- /* ------------------------------------------------------------ */
- /**
- * Close the log file and perform cleanup.
- *
- * @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
- */
@Override
protected void doStop() throws Exception
{
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Slf4jRequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Slf4jRequestLog.java
index 29388a227f9..a6340c9f399 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Slf4jRequestLog.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Slf4jRequestLog.java
@@ -24,7 +24,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
/**
* Implementation of NCSARequestLog where output is sent as a SLF4J INFO Log message on the named logger "org.eclipse.jetty.server.RequestLog"
- * @deprecated use {@link CustomRequestLog} given format string {@link CustomRequestLog#NCSA_FORMAT} with an {@link Slf4jRequestLogWriter}
+ * @deprecated use {@link CustomRequestLog} given format string {@link CustomRequestLog#EXTENDED_NCSA_FORMAT} with an {@link Slf4jRequestLogWriter}
*/
@Deprecated
@ManagedObject("NCSA standard format request log to slf4j bridge")