Search in sources :

Example 41 with RequestLogHandler

use of org.eclipse.jetty.server.handler.RequestLogHandler in project druid by druid-io.

the class JettyServerInitUtils method getJettyRequestLogHandler.

public static Handler getJettyRequestLogHandler() {
    // Ref: http://www.eclipse.org/jetty/documentation/9.2.6.v20141205/configuring-jetty-request-logs.html
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(new JettyRequestLog());
    return requestLogHandler;
}
Also used : RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler)

Example 42 with RequestLogHandler

use of org.eclipse.jetty.server.handler.RequestLogHandler in project killbill by killbill.

the class HttpServer method configure.

public void configure(final HttpServerConfig config, final Iterable<EventListener> eventListeners, final Map<FilterHolder, String> filterHolders) {
    server.setStopAtShutdown(true);
    // Setup JMX
    configureJMX(ManagementFactory.getPlatformMBeanServer());
    // HTTP Configuration
    final HttpConfiguration httpConfiguration = new HttpConfiguration();
    httpConfiguration.setSecurePort(config.getServerSslPort());
    // Configure main connector
    final ServerConnector http = configureMainConnector(httpConfiguration, config.isJettyStatsOn(), config.getServerHost(), config.getServerPort());
    // Configure SSL, if enabled
    final ServerConnector https;
    if (config.isSSLEnabled()) {
        https = configureSslConnector(httpConfiguration, config.isJettyStatsOn(), config.getServerSslPort(), config.getSSLkeystoreLocation(), config.getSSLkeystorePassword());
        server.setConnectors(new Connector[] { http, https });
    } else {
        server.setConnectors(new Connector[] { http });
    }
    // Configure the thread pool
    configureThreadPool(config);
    // Configure handlers
    final HandlerCollection handlers = new HandlerCollection();
    final ServletContextHandler servletContextHandler = createServletContextHandler(config.getResourceBase(), eventListeners, filterHolders);
    handlers.addHandler(servletContextHandler);
    final RequestLogHandler logHandler = createLogHandler(config);
    handlers.addHandler(logHandler);
    final HandlerList rootHandlers = new HandlerList();
    rootHandlers.addHandler(handlers);
    server.setHandler(rootHandlers);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) HandlerList(org.eclipse.jetty.server.handler.HandlerList) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 43 with RequestLogHandler

use of org.eclipse.jetty.server.handler.RequestLogHandler in project killbill by killbill.

the class HttpServer method createLogHandler.

private RequestLogHandler createLogHandler(final HttpServerConfig config) {
    final RequestLogHandler logHandler = new RequestLogHandler();
    final RequestLog requestLog = new NCSARequestLog(config.getLogPath());
    logHandler.setRequestLog(requestLog);
    return logHandler;
}
Also used : NCSARequestLog(org.eclipse.jetty.server.NCSARequestLog) RequestLog(org.eclipse.jetty.server.RequestLog) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) NCSARequestLog(org.eclipse.jetty.server.NCSARequestLog)

Example 44 with RequestLogHandler

use of org.eclipse.jetty.server.handler.RequestLogHandler in project vespa by vespa-engine.

the class JettyHttpServer method getHandlerCollection.

private HandlerCollection getHandlerCollection(ServerConfig serverConfig, ServletPathsConfig servletPathsConfig, ServletHolder jdiscServlet, ComponentRegistry<ServletHolder> servletHolders, FilterHolder jDiscFilterInvokerFilter, RequestLog requestLog) {
    ServletContextHandler servletContextHandler = createServletContextHandler();
    servletHolders.allComponentsById().forEach((id, servlet) -> {
        String path = getServletPath(servletPathsConfig, id);
        servletContextHandler.addServlet(servlet, path);
        servletContextHandler.addFilter(jDiscFilterInvokerFilter, path, EnumSet.allOf(DispatcherType.class));
    });
    servletContextHandler.addServlet(jdiscServlet, "/*");
    GzipHandler gzipHandler = newGzipHandler(serverConfig);
    gzipHandler.setHandler(servletContextHandler);
    StatisticsHandler statisticsHandler = newStatisticsHandler();
    statisticsHandler.setHandler(gzipHandler);
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(new Handler[] { statisticsHandler, requestLogHandler });
    return handlerCollection;
}
Also used : GzipHandler(org.eclipse.jetty.server.handler.gzip.GzipHandler) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) DispatcherType(javax.servlet.DispatcherType) StatisticsHandler(org.eclipse.jetty.server.handler.StatisticsHandler)

Example 45 with RequestLogHandler

use of org.eclipse.jetty.server.handler.RequestLogHandler in project helios by spotify.

the class MasterService method setUpRequestLogging.

private void setUpRequestLogging(final Path stateDirectory) {
    // Set up request logging
    final Handler originalHandler = server.getHandler();
    final HandlerCollection handlerCollection;
    if (originalHandler instanceof HandlerCollection) {
        handlerCollection = (HandlerCollection) originalHandler;
    } else {
        handlerCollection = new HandlerCollection();
        handlerCollection.addHandler(originalHandler);
    }
    final RequestLogHandler requestLogHandler = new RequestLogHandler();
    final RequestLogImpl requestLog = new RequestLogImpl();
    requestLog.setQuiet(true);
    if (stateDirectory.resolve(LOGBACK_ACCESS_CONFIG).toFile().exists()) {
        requestLog.setFileName(stateDirectory.resolve(LOGBACK_ACCESS_CONFIG).toString());
    } else if (this.getClass().getResource(LOGBACK_ACCESS_RESOURCE) != null) {
        requestLog.setResource(LOGBACK_ACCESS_RESOURCE);
    }
    requestLogHandler.setRequestLog(requestLog);
    handlerCollection.addHandler(requestLogHandler);
    server.setHandler(handlerCollection);
}
Also used : RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) RequestLogImpl(ch.qos.logback.access.jetty.RequestLogImpl) Handler(org.eclipse.jetty.server.Handler) RequestLogHandler(org.eclipse.jetty.server.handler.RequestLogHandler) HandlerCollection(org.eclipse.jetty.server.handler.HandlerCollection)

Aggregations

RequestLogHandler (org.eclipse.jetty.server.handler.RequestLogHandler)45 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)30 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)25 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)22 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)18 Handler (org.eclipse.jetty.server.Handler)14 Slf4jRequestLog (org.eclipse.jetty.server.Slf4jRequestLog)13 Server (org.eclipse.jetty.server.Server)12 ServerConnector (org.eclipse.jetty.server.ServerConnector)12 StatisticsHandler (org.eclipse.jetty.server.handler.StatisticsHandler)10 RequestLog (org.eclipse.jetty.server.RequestLog)8 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)8 File (java.io.File)7 IOException (java.io.IOException)7 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)7 ContextHandler (org.eclipse.jetty.server.handler.ContextHandler)7 NCSARequestLog (org.eclipse.jetty.server.NCSARequestLog)6 JacksonJsonProvider (com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider)5 Test (org.junit.Test)5 HttpURLConnection (java.net.HttpURLConnection)4