Fixes #4460 - Provide a parameterless CustomRequestLog.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2020-01-09 16:39:03 +01:00
parent c19d35b34f
commit a1f155b44a
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()
{