Avoid using deprecated NCSARequestLog

See gh-16987
pull/17049/head
dreis2211 6 years ago committed by Phillip Webb
parent 9ad19349f4
commit 4af3badbea

@ -22,8 +22,9 @@ import javax.servlet.Filter;
import org.apache.catalina.Valve; import org.apache.catalina.Valve;
import org.apache.catalina.valves.AccessLogValve; import org.apache.catalina.valves.AccessLogValve;
import org.eclipse.jetty.server.NCSARequestLog; import org.eclipse.jetty.server.CustomRequestLog;
import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.server.RequestLog;
import org.eclipse.jetty.server.RequestLogWriter;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
@ -194,17 +195,21 @@ class ServletManagementChildContextConfiguration {
private void customizeServer(Server server) { private void customizeServer(Server server) {
RequestLog requestLog = server.getRequestLog(); RequestLog requestLog = server.getRequestLog();
if (requestLog != null && requestLog instanceof NCSARequestLog) { if (requestLog != null && requestLog instanceof CustomRequestLog) {
customizeRequestLog((NCSARequestLog) requestLog); customizeRequestLog((CustomRequestLog) requestLog);
} }
} }
private void customizeRequestLog(NCSARequestLog requestLog) { private void customizeRequestLog(CustomRequestLog requestLog) {
String filename = requestLog.getFilename(); if (requestLog.getWriter() instanceof RequestLogWriter) {
if (StringUtils.hasLength(filename)) { RequestLogWriter writer = (RequestLogWriter) requestLog.getWriter();
File file = new File(filename); String filename = writer.getFileName();
file = new File(file.getParentFile(), customizePrefix(file.getName())); if (StringUtils.hasLength(filename)) {
requestLog.setFilename(file.getPath()); File file = new File(filename);
file = new File(file.getParentFile(),
customizePrefix(file.getName()));
writer.setFilename(file.getPath());
}
} }
} }

Loading…
Cancel
Save