Always include peer port/address in access log
@@ -58,23 +58,24 @@ public class AccessLogRequestLog extends AbstractLifeCycle implements RequestLog
accessLogEntry.setRawQuery(queryString);
}
- final String remoteAddress = getRemoteAddress(request);
- final int remotePort = getRemotePort(request);
- final String peerAddress = request.getRemoteAddr();
- final int peerPort = request.getRemotePort();
-
accessLogEntry.setUserAgent(request.getHeader("User-Agent"));
accessLogEntry.setHttpMethod(request.getMethod());
accessLogEntry.setHostString(request.getHeader("Host"));
accessLogEntry.setReferer(request.getHeader("Referer"));
+
+ String peerAddress = request.getRemoteAddr();
accessLogEntry.setIpV4Address(peerAddress);
- accessLogEntry.setRemoteAddress(remoteAddress);
- accessLogEntry.setRemotePort(remotePort);
- if (!Objects.equal(remoteAddress, peerAddress)) {
accessLogEntry.setPeerAddress(peerAddress);
+ String remoteAddress = getRemoteAddress(request);
+ if (!Objects.equal(remoteAddress, peerAddress)) {
+ accessLogEntry.setRemoteAddress(remoteAddress);
}
- if (remotePort != peerPort) {
+
+ int peerPort = request.getRemotePort();
accessLogEntry.setPeerPort(peerPort);
+ int remotePort = getRemotePort(request);
+ if (remotePort != peerPort) {
+ accessLogEntry.setRemotePort(remotePort);
}
accessLogEntry.setHttpVersion(request.getProtocol());
accessLogEntry.setScheme(request.getScheme());
