This is an automated email from the ASF dual-hosted git repository. zhangduo pushed a commit to branch branch-2 in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push: new 7ff1d14 HBASE-25688 Use CustomRequestLog instead of Slf4jRequestLog for jetty (#3075) 7ff1d14 is described below commit 7ff1d1495947d222e3d587dd8de8067cd2c06a8b Author: Duo Zhang <zhang...@apache.org> AuthorDate: Tue Mar 23 08:34:49 2021 +0800 HBASE-25688 Use CustomRequestLog instead of Slf4jRequestLog for jetty (#3075) Signed-off-by: stack <st...@apache.org> --- .../main/java/org/apache/hadoop/hbase/http/HttpRequestLog.java | 9 +++++---- .../java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java | 10 ++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpRequestLog.java b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpRequestLog.java index 57f40c4..d3e8005 100644 --- a/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpRequestLog.java +++ b/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpRequestLog.java @@ -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() { diff --git a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java index e8a6b06..1efc116 100644 --- a/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java +++ b/hbase-http/src/test/java/org/apache/hadoop/hbase/http/TestHttpRequestLog.java @@ -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()); } }