mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge pull request #16987 from dreis2211
* pr/16987: Polish "Avoid using deprecated NCSARequestLog" Avoid using deprecated NCSARequestLog Closes gh-16987
This commit is contained in:
commit
063bb907a4
@ -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,23 @@ 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) {
|
||||
customizeRequestLogWriter((RequestLogWriter) requestLog.getWriter());
|
||||
}
|
||||
}
|
||||
|
||||
private void customizeRequestLogWriter(RequestLogWriter writer) {
|
||||
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());
|
||||
writer.setFilename(file.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user