HBASE-25688 Use CustomRequestLog instead of Slf4jRequestLog for jetty (#3075)
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
parent
4cf28c43f5
commit
a4dad396b0
|
@ -20,8 +20,9 @@ package org.apache.hadoop.hbase.http;
|
|||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
import org.apache.hbase.thirdparty.com.google.common.collect.ImmutableMap;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.CustomRequestLog;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLog;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLogWriter;
|
||||
|
||||
/**
|
||||
* RequestLog object for use with Http
|
||||
|
@ -38,9 +39,9 @@ public final class HttpRequestLog {
|
|||
name = lookup;
|
||||
}
|
||||
String loggerName = "http.requests." + name;
|
||||
Slf4jRequestLog logger = new Slf4jRequestLog();
|
||||
logger.setLoggerName(loggerName);
|
||||
return logger;
|
||||
Slf4jRequestLogWriter writer = new Slf4jRequestLogWriter();
|
||||
writer.setLoggerName(loggerName);
|
||||
return new CustomRequestLog(writer, CustomRequestLog.EXTENDED_NCSA_FORMAT);
|
||||
}
|
||||
|
||||
private HttpRequestLog() {
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.http;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
|
@ -27,8 +29,9 @@ import org.junit.ClassRule;
|
|||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.CustomRequestLog;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.RequestLog;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLog;
|
||||
import org.apache.hbase.thirdparty.org.eclipse.jetty.server.Slf4jRequestLogWriter;
|
||||
|
||||
@Category({ MiscTests.class, SmallTests.class })
|
||||
public class TestHttpRequestLog {
|
||||
|
@ -41,6 +44,9 @@ public class TestHttpRequestLog {
|
|||
public void testAppenderDefined() {
|
||||
RequestLog requestLog = HttpRequestLog.getRequestLog("test");
|
||||
assertNotNull("RequestLog should not be null", requestLog);
|
||||
assertEquals("Class mismatch", Slf4jRequestLog.class, requestLog.getClass());
|
||||
assertThat(requestLog, instanceOf(CustomRequestLog.class));
|
||||
CustomRequestLog crl = (CustomRequestLog) requestLog;
|
||||
assertThat(crl.getWriter(), instanceOf(Slf4jRequestLogWriter.class));
|
||||
assertEquals(CustomRequestLog.EXTENDED_NCSA_FORMAT, crl.getFormatString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue