This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git
The following commit(s) were added to refs/heads/master by this push: new 0bf3494 add slf4j handler to log web-server log (#2408) 0bf3494 is described below commit 0bf3494dc2e941e53a495c92310f3847aa11fd09 Author: Rajan Dhabalia <rdhaba...@apache.org> AuthorDate: Mon Aug 20 13:47:48 2018 -0700 add slf4j handler to log web-server log (#2408) --- .../apache/pulsar/functions/worker/rest/WorkerServer.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/WorkerServer.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/WorkerServer.java index 3e9a426..1c26c7d 100644 --- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/WorkerServer.java +++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/WorkerServer.java @@ -21,6 +21,8 @@ package org.apache.pulsar.functions.worker.rest; import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import java.util.TimeZone; + import javax.servlet.DispatcherType; import lombok.extern.slf4j.Slf4j; import org.apache.pulsar.broker.web.AuthenticationFilter; @@ -32,6 +34,7 @@ import org.apache.pulsar.functions.worker.WorkerService; import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.server.Slf4jRequestLog; import java.net.BindException; import java.net.URI; @@ -39,6 +42,7 @@ import java.security.GeneralSecurityException; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; @@ -98,10 +102,19 @@ public class WorkerServer { newServletContextHandler("/admin/v2", new ResourceConfig(Resources.getApiResources()), workerService)); handlers.add(newServletContextHandler("/", new ResourceConfig(Resources.getRootResources()), workerService)); + RequestLogHandler requestLogHandler = new RequestLogHandler(); + Slf4jRequestLog requestLog = new Slf4jRequestLog(); + requestLog.setExtended(true); + requestLog.setLogTimeZone(TimeZone.getDefault().getID()); + requestLog.setLogLatency(true); + requestLogHandler.setRequestLog(requestLog); + handlers.add(0, new ContextHandlerCollection()); + handlers.add(requestLogHandler); + ContextHandlerCollection contexts = new ContextHandlerCollection(); contexts.setHandlers(handlers.toArray(new Handler[handlers.size()])); HandlerCollection handlerCollection = new HandlerCollection(); - handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler() }); + handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler }); server.setHandler(handlerCollection); if (this.workerConfig.isTlsEnabled()) {