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