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.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.RequestLogWriter;
import org.eclipse.jetty.server.Server;
import org.springframework.beans.factory.BeanFactory;
@ -194,17 +195,21 @@ class ServletManagementChildContextConfiguration {
private void customizeServer(Server server) {
RequestLog requestLog = server.getRequestLog();
if (requestLog != null && requestLog instanceof NCSARequestLog) {
customizeRequestLog((NCSARequestLog) requestLog);
if (requestLog != null && requestLog instanceof CustomRequestLog) {
customizeRequestLog((CustomRequestLog) requestLog);
}
}
private void customizeRequestLog(NCSARequestLog requestLog) {
String filename = requestLog.getFilename();
private void customizeRequestLog(CustomRequestLog requestLog) {
if (requestLog.getWriter() instanceof RequestLogWriter) {
RequestLogWriter writer = (RequestLogWriter) requestLog.getWriter();
String filename = writer.getFileName();
if (StringUtils.hasLength(filename)) {
File file = new File(filename);
file = new File(file.getParentFile(), customizePrefix(file.getName()));
requestLog.setFilename(file.getPath());
file = new File(file.getParentFile(),
customizePrefix(file.getName()));
writer.setFilename(file.getPath());
}
}
}

Loading…
Cancel
Save