ARTEMIS-3658 remove refs to Jetty's deprecated NCSARequestLog

This commit is contained in:
Justin Bertram 2022-01-27 07:32:55 -06:00 committed by clebertsuconic
parent 9c459eb313
commit d377a5a638
3 changed files with 60 additions and 64 deletions

View File

@ -46,12 +46,14 @@ public class RequestLogDTO {
/** /**
* logging of the request cookies * logging of the request cookies
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public Boolean logCookies; public Boolean logCookies;
/** /**
* the output file name of the request log * the output file name of the request log
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public String logTimeZone; public String logTimeZone;
@ -76,30 +78,41 @@ public class RequestLogDTO {
/** /**
* the timestamp format string for request log entries * the timestamp format string for request log entries
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public String logDateFormat; public String logDateFormat;
/** /**
* the locale of the request log * the locale of the request log
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public String logLocale; public String logLocale;
/** /**
* logging of request processing time * logging of request processing time
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public Boolean logLatency; public Boolean logLatency;
/** /**
* logging of the request hostname * logging of the request hostname
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public Boolean logServer; public Boolean logServer;
/** /**
* whether the actual IP address of the connection or the IP address from the X-Forwarded-For header will be logged * whether the actual IP address of the connection or the IP address from the X-Forwarded-For header will be logged
*/ */
@Deprecated
@XmlAttribute @XmlAttribute
public Boolean preferProxiedForAddress; public Boolean preferProxiedForAddress;
/**
* the format to use for logging; see https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/server/CustomRequestLog.html
*/
@XmlAttribute
public String format;
} }

View File

@ -16,6 +16,17 @@
*/ */
package org.apache.activemq.artemis.component; package org.apache.activemq.artemis.component;
import javax.servlet.DispatcherType;
import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.activemq.artemis.ActiveMQWebLogger; import org.apache.activemq.artemis.ActiveMQWebLogger;
import org.apache.activemq.artemis.components.ExternalComponent; import org.apache.activemq.artemis.components.ExternalComponent;
import org.apache.activemq.artemis.dto.AppDTO; import org.apache.activemq.artemis.dto.AppDTO;
@ -24,9 +35,10 @@ import org.apache.activemq.artemis.dto.ComponentDTO;
import org.apache.activemq.artemis.dto.WebServerDTO; import org.apache.activemq.artemis.dto.WebServerDTO;
import org.eclipse.jetty.security.DefaultAuthenticatorFactory; import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
import org.eclipse.jetty.server.ConnectionFactory; import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.server.CustomRequestLog;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.RequestLogWriter;
import org.eclipse.jetty.server.SecureRequestCustomizer; import org.eclipse.jetty.server.SecureRequestCustomizer;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
@ -41,18 +53,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import javax.servlet.DispatcherType;
import java.io.File;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
public class WebServerComponent implements ExternalComponent { public class WebServerComponent implements ExternalComponent {
private static final Logger logger = Logger.getLogger(WebServerComponent.class); private static final Logger logger = Logger.getLogger(WebServerComponent.class);
@ -209,34 +209,30 @@ public class WebServerComponent implements ExternalComponent {
} }
private RequestLogHandler getLogHandler() { private RequestLogHandler getLogHandler() {
RequestLogHandler requestLogHandler = new RequestLogHandler(); RequestLogWriter requestLogWriter = new RequestLogWriter();
NCSARequestLog requestLog = new NCSARequestLog(); CustomRequestLog requestLog;
// required via config so no check necessary // required via config so no check necessary
requestLog.setFilename(webServerConfig.requestLog.filename); requestLogWriter.setFilename(webServerConfig.requestLog.filename);
if (webServerConfig.requestLog.append != null) { if (webServerConfig.requestLog.append != null) {
requestLog.setAppend(webServerConfig.requestLog.append); requestLogWriter.setAppend(webServerConfig.requestLog.append);
}
if (webServerConfig.requestLog.extended != null) {
requestLog.setExtended(webServerConfig.requestLog.extended);
}
if (webServerConfig.requestLog.logCookies != null) {
requestLog.setLogCookies(webServerConfig.requestLog.logCookies);
}
if (webServerConfig.requestLog.logTimeZone != null) {
requestLog.setLogTimeZone(webServerConfig.requestLog.logTimeZone);
} }
if (webServerConfig.requestLog.filenameDateFormat != null) { if (webServerConfig.requestLog.filenameDateFormat != null) {
requestLog.setFilenameDateFormat(webServerConfig.requestLog.filenameDateFormat); requestLogWriter.setFilenameDateFormat(webServerConfig.requestLog.filenameDateFormat);
} }
if (webServerConfig.requestLog.retainDays != null) { if (webServerConfig.requestLog.retainDays != null) {
requestLog.setRetainDays(webServerConfig.requestLog.retainDays); requestLogWriter.setRetainDays(webServerConfig.requestLog.retainDays);
}
if (webServerConfig.requestLog.format != null) {
requestLog = new CustomRequestLog(requestLogWriter, webServerConfig.requestLog.format);
} else if (webServerConfig.requestLog.extended != null && webServerConfig.requestLog.extended) {
requestLog = new CustomRequestLog(requestLogWriter, CustomRequestLog.EXTENDED_NCSA_FORMAT);
} else {
requestLog = new CustomRequestLog(requestLogWriter, CustomRequestLog.NCSA_FORMAT);
} }
if (webServerConfig.requestLog.ignorePaths != null && webServerConfig.requestLog.ignorePaths.length() > 0) { if (webServerConfig.requestLog.ignorePaths != null && webServerConfig.requestLog.ignorePaths.length() > 0) {
@ -248,28 +244,8 @@ public class WebServerComponent implements ExternalComponent {
requestLog.setIgnorePaths(ignorePaths); requestLog.setIgnorePaths(ignorePaths);
} }
if (webServerConfig.requestLog.logDateFormat != null) { RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLog.setLogDateFormat(webServerConfig.requestLog.logDateFormat);
}
if (webServerConfig.requestLog.logLocale != null) {
requestLog.setLogLocale(Locale.forLanguageTag(webServerConfig.requestLog.logLocale));
}
if (webServerConfig.requestLog.logLatency != null) {
requestLog.setLogLatency(webServerConfig.requestLog.logLatency);
}
if (webServerConfig.requestLog.logServer != null) {
requestLog.setLogServer(webServerConfig.requestLog.logServer);
}
if (webServerConfig.requestLog.preferProxiedForAddress != null) {
requestLog.setPreferProxiedForAddress(webServerConfig.requestLog.preferProxiedForAddress);
}
requestLogHandler.setRequestLog(requestLog); requestLogHandler.setRequestLog(requestLog);
return requestLogHandler; return requestLogHandler;
} }

View File

@ -68,23 +68,30 @@ It's also possible to configure HTTP/S request logging via the `request-log`
element which has the following attributes: element which has the following attributes:
- `filename` The full path of the request log. This attribute is required. - `filename` The full path of the request log. This attribute is required.
- `append` Whether or not to append to the existing log or truncate it. Boolean flag. - `append` Whether or not to append to the existing log or truncate it. Boolean
- `extended` Whether or not to use the extended request log format. Boolean flag. flag.
- `logCookies` Logging of the request cookies. Boolean flag. - `extended` Whether or not to use the extended request log format. Boolean
- `logTimeZone` The output file name of the request log. flag. If `true` will use the format `%{client}a - %u %t "%r" %s %O
"%{Referer}i" "%{User-Agent}i"`. If `false` will use the format `%{client}a -
%u %t "%r" %s %O`. Default is `false`. See the [format
specification](https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/server/CustomRequestLog.html)
for more details.
- `filenameDateFormat` The log file name date format. - `filenameDateFormat` The log file name date format.
- `retainDays` The number of days before rotated log files are deleted. - `retainDays` The number of days before rotated log files are deleted.
- `ignorePaths` Request paths that will not be logged. Comma delimited list. - `ignorePaths` Request paths that will not be logged. Comma delimited list.
- `logDateFormat` The timestamp format string for request log entries. - `format` Custom format to use. If set this will override `extended`. See the
- `logLocale` The locale of the request log. [format specification](https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/server/CustomRequestLog.html)
- `logLatency` Logging of request processing time. Boolean flag. for more details.
- `logServer` Logging of the request hostname. Boolean flag.
- `preferProxiedForAddress` Whether the actual IP address of the connection or The following options were previously supported, but they were replaced by the
the IP address from the `X-Forwarded-For` header will be logged. Boolean flag. `format`: `logCookie`, `logTimeZone`, `logDateFormat`, `logLocale`,
`logLatency`, `logServer`, `preferProxiedForAddress`. All these options are now
deprecated and ignored.
These attributes are essentially passed straight through to the underlying These attributes are essentially passed straight through to the underlying
[`org.eclipse.jetty.server.NCSARequestLog`](https://www.eclipse.org/jetty/javadoc/current/org/eclipse/jetty/server/NCSARequestLog.html) [`org.eclipse.jetty.server.CustomRequestLog`](https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/server/CustomRequestLog.html)
instance. Default values are based on this implementation. and [`org.eclipse.jetty.server.RequestLogWriter`](https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/server/RequestLogWriter.html)
instances. Default values are based on these implementations.
Here is an example configuration: Here is an example configuration: