Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4460 - Provide a parameterless CustomRequestLog. #4470

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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;
Expand All @@ -303,16 +318,6 @@ public CustomRequestLog(RequestLog.Writer writer, String formatString)
}
}

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()
{
Expand Down