Merge pull request #4470 from eclipse/jetty-10.0.x-4460-custom_request_log_no_parameters

Fixes #4460 - Provide a parameterless CustomRequestLog.
This commit is contained in:
Simone Bordet 2020-01-09 17:36:42 +01:00 committed by GitHub
commit b2907f85f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 11 deletions

View File

@ -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<StringBuilder> _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()
{