From d33e4dc6f9734c279511e1ab735bbd7de05d7d97 Mon Sep 17 00:00:00 2001 From: Ivan Bodrov Date: Tue, 29 Oct 2019 15:38:31 -0400 Subject: [PATCH] allow custom access logs --- .../main/java/com/walmartlabs/ollie/OllieServer.java | 12 ++++++------ .../com/walmartlabs/ollie/OllieServerBuilder.java | 12 ++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ollie/src/main/java/com/walmartlabs/ollie/OllieServer.java b/ollie/src/main/java/com/walmartlabs/ollie/OllieServer.java index 70daf18..84ecc33 100644 --- a/ollie/src/main/java/com/walmartlabs/ollie/OllieServer.java +++ b/ollie/src/main/java/com/walmartlabs/ollie/OllieServer.java @@ -63,12 +63,7 @@ import javax.servlet.SessionCookieConfig; import javax.servlet.http.HttpServlet; import org.eclipse.jetty.jmx.MBeanContainer; -import org.eclipse.jetty.server.HttpConfiguration; -import org.eclipse.jetty.server.HttpConnectionFactory; -import org.eclipse.jetty.server.SecureRequestCustomizer; -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.server.ServerConnector; -import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.server.*; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.ResourceHandler; @@ -306,6 +301,11 @@ public Server build(OllieServerBuilder builder) { statisticsHandler.setHandler(contextHandlerCollection); server.setHandler(statisticsHandler); + RequestLog requestLog = builder.requestLog(); + if (requestLog != null) { + server.setRequestLog(requestLog); + } + return server; } diff --git a/ollie/src/main/java/com/walmartlabs/ollie/OllieServerBuilder.java b/ollie/src/main/java/com/walmartlabs/ollie/OllieServerBuilder.java index d5d7f42..8971963 100644 --- a/ollie/src/main/java/com/walmartlabs/ollie/OllieServerBuilder.java +++ b/ollie/src/main/java/com/walmartlabs/ollie/OllieServerBuilder.java @@ -33,6 +33,7 @@ import com.walmartlabs.ollie.model.StaticResourceDefinition; import org.apache.shiro.realm.Realm; import org.eclipse.jetty.security.SecurityHandler; +import org.eclipse.jetty.server.RequestLog; import org.eclipse.jetty.servlets.CrossOriginFilter; import javax.servlet.Filter; @@ -97,6 +98,8 @@ public class OllieServerBuilder { Set shutdownListeners = Sets.newHashSet(); private String webServletsPath; + private RequestLog requestLog; + public OllieServer build() { filter("/*").through(CrossOriginFilter.class); filter("/*").through(GuiceFilter.class); @@ -432,4 +435,13 @@ public OllieServerBuilder serveWebServlets(String webServletsPath) { public String webServletsPath() { return webServletsPath; } + + public OllieServerBuilder requestLog(RequestLog requestLog) { + this.requestLog = requestLog; + return this; + } + + public RequestLog requestLog() { + return requestLog; + } }