From a1f155b44abe47e7462b2a7a9fd13c1c4ad9ba4b Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Thu, 9 Jan 2020 16:39:03 +0100 Subject: [PATCH] Fixes #4460 - Provide a parameterless CustomRequestLog. Signed-off-by: Simone Bordet --- .../jetty/server/CustomRequestLog.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java index 46f82b66254..56bf1de0bf6 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/CustomRequestLog.java @@ -276,7 +276,7 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog public static final String DEFAULT_DATE_FORMAT = "dd/MMM/yyyy:HH:mm:ss ZZZ"; public static final String NCSA_FORMAT = "%{client}a - %u %t \"%r\" %s %O"; - public static final String EXTENDED_NCSA_FORMAT = "%{client}a - %u %t \"%r\" %s %O \"%{Referer}i\" \"%{User-Agent}i\""; + public static final String EXTENDED_NCSA_FORMAT = NCSA_FORMAT + " \"%{Referer}i\" \"%{User-Agent}i\""; private static ThreadLocal _buffers = ThreadLocal.withInitial(() -> new StringBuilder(256)); @@ -287,6 +287,21 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog private final MethodHandle _logHandle; private final String _formatString; + public CustomRequestLog() + { + this(new Slf4jRequestLogWriter(), EXTENDED_NCSA_FORMAT); + } + + public CustomRequestLog(String file) + { + this(file, EXTENDED_NCSA_FORMAT); + } + + public CustomRequestLog(String file, String format) + { + this(new RequestLogWriter(file), format); + } + public CustomRequestLog(RequestLog.Writer writer, String formatString) { _formatString = formatString; @@ -303,16 +318,6 @@ public class CustomRequestLog extends ContainerLifeCycle implements RequestLog } } - public CustomRequestLog(String file) - { - this(file, EXTENDED_NCSA_FORMAT); - } - - public CustomRequestLog(String file, String format) - { - this(new RequestLogWriter(file), format); - } - @ManagedAttribute("The RequestLogWriter") public RequestLog.Writer getWriter() {