當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestLogHandler類代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.handler.RequestLogHandler的典型用法代碼示例。如果您正苦於以下問題:Java RequestLogHandler類的具體用法?Java RequestLogHandler怎麽用?Java RequestLogHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RequestLogHandler類屬於org.eclipse.jetty.server.handler包,在下文中一共展示了RequestLogHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jettyConfigBean

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {

    DynamicPropertyFactory propertyFactory = DynamicPropertyFactory.getInstance();
    String accessLogFilePath = propertyFactory.getStringProperty("server.accessLog.config.file", ACCESS_LOG_FILE_PATH).getValue();

    JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory
            = new JettyEmbeddedServletContainerFactory();
    jettyEmbeddedServletContainerFactory.addServerCustomizers(new org.springframework.boot.context.embedded.jetty.JettyServerCustomizer() {
        public void customize(Server server) {
            HandlerCollection handlers = new HandlerCollection();
            for (Handler handler : server.getHandlers()) {
                handlers.addHandler(handler);
            }
            RequestLogHandler requestLogHandler = new RequestLogHandler();
            RequestLogImpl requestLogImpl = new RequestLogImpl();
            requestLogImpl.setFileName(accessLogFilePath);
            requestLogHandler.setRequestLog(requestLogImpl);
            handlers.addHandler(requestLogHandler);
            server.setHandler(handlers);
            LOGGER.info("Jetty Server Customized. Access Log Configuration File - {}", accessLogFilePath);
        }
    });
    return jettyEmbeddedServletContainerFactory;
}
 
開發者ID:andrewharmellaw,項目名稱:jetty-server-request-logger,代碼行數:26,代碼來源:JettyServerCustomizer.java

示例2: start

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
public void start() throws Exception {
    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(), requestLogHandler });
    server.setHandler(handlerCollection);

    server.start();

    log.info("Server started at end point {}", getServiceUri());
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:22,代碼來源:ServerManager.java

示例3: start

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
public void start() throws PulsarServerException {
    log.info("Starting web socket proxy at port {}", conf.getWebServicePort());
    try {
        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(), requestLogHandler });
        server.setHandler(handlerCollection);

        server.start();
    } catch (Exception e) {
        throw new PulsarServerException(e);
    }
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:25,代碼來源:ProxyServer.java

示例4: start

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
public void start() throws PulsarServerException {
    try {
        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(), requestLogHandler });
        server.setHandler(handlerCollection);

        server.start();

        log.info("Web Service started at {}", pulsar.getWebServiceAddress());
    } catch (Exception e) {
        throw new PulsarServerException(e);
    }
}
 
開發者ID:apache,項目名稱:incubator-pulsar,代碼行數:26,代碼來源:WebService.java

示例5: start

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
public void start() throws Exception {
  server = new Server();
  Connector connector = new SelectChannelConnector();
  connector.setPort(port);
  server.setConnectors(new Connector[]{connector});

  RequestLogHandler requestLogHandler = new RequestLogHandler();
  configureRequestLogImpl();
  requestLogHandler.setRequestLog(requestLogImpl);

  HandlerList handlers = new HandlerList();
  handlers.addHandler(requestLogHandler);
  handlers.addHandler(getRequestHandler());

  server.setHandler(handlers);
  server.start();
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:18,代碼來源:JettyFixtureBase.java

示例6: customizeServer

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
@Override
public void customizeServer(Server server) {
    if(logFile != null) {
    HandlerCollection rootHandler = (HandlerCollection) server.getHandler();

    List<Handler> handlers = new ArrayList<Handler>();

    handlers.addAll(Arrays.asList(rootHandler.getHandlers()));

    RequestLogHandler requestLogHandler = new RequestLogHandler();

    NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
    requestLog.setRetainDays(0);
    requestLog.setAppend(true);
    requestLog.setExtended(extended);
    requestLog.setLogTimeZone("GMT");
    requestLogHandler.setRequestLog(requestLog);

    handlers.add(requestLogHandler);

    rootHandler.setHandlers(handlers.toArray(new Handler[handlers.size()]));

    }
}
 
開發者ID:eirbjo,項目名稱:jetty-console,代碼行數:25,代碼來源:RequestLogPlugin.java

示例7: setRequestLogHandler

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
private static RequestLogHandler setRequestLogHandler() {
	ConfigureAdaptor conf = ConfigureManager.getConfigure();

	NCSARequestLog requestLog = new NCSARequestLog();
	requestLog.setFilename("./logs/http-request-yyyy_mm_dd.log");
	requestLog.setFilenameDateFormat("yyyy_MM_dd");
	requestLog.setRetainDays(conf.getLogKeepDays());
	requestLog.setAppend(true);
	requestLog.setExtended(true);
	requestLog.setLogCookies(false);
	requestLog.setLogTimeZone(TimeZone.getDefault().getID());
	RequestLogHandler requestLogHandler = new RequestLogHandler();
	requestLogHandler.setRequestLog(requestLog);

	return requestLogHandler;
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:17,代碼來源:WebAppMain.java

示例8: createHandlers

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
private static HandlerCollection createHandlers(
        final GatewayConfig config,
        final GatewayServices services,
        final ContextHandlerCollection contexts) {
    HandlerCollection handlers = new HandlerCollection();
    RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new AccessHandler());

    TraceHandler traceHandler = new TraceHandler();
    traceHandler.setHandler(contexts);
    traceHandler.setTracedBodyFilter(System.getProperty("org.apache.knox.gateway.trace.body.status.filter"));

    CorrelationHandler correlationHandler = new CorrelationHandler();
    correlationHandler.setHandler(traceHandler);

    DefaultTopologyHandler defaultTopoHandler = new DefaultTopologyHandler(config, services, contexts);

    handlers.setHandlers(new Handler[]{correlationHandler, defaultTopoHandler, logHandler});
    return handlers;
}
 
開發者ID:sakserv,項目名稱:hadoop-mini-clusters,代碼行數:21,代碼來源:GatewayServer.java

示例9: customizeJetty

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
@Override
void customizeJetty(JettyEmbeddedServletContainerFactory container) {
    container.addServerCustomizers(server -> {
        RequestLogHandler requestLogsHandler = new RequestLogHandler();
        requestLogsHandler.setServer(server);
        Slf4jRequestLog log = new Slf4jRequestLog();
        requestLogsHandler.setRequestLog(log);

        HandlerCollection handlers = new HandlerCollection(server.getHandlers());
        handlers.prependHandler(requestLogsHandler);
        server.setHandler(handlers);
    });
}
 
開發者ID:amvnetworks,項目名稱:amv-access-api-poc,代碼行數:14,代碼來源:JettyAccessLogCustomizer.java

示例10: test_embeddedServer_withHandlerChain

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
@Test
public void test_embeddedServer_withHandlerChain() throws Exception {
    AtomicLong logCount = new AtomicLong(0);
    RequestLog requestLog = (request, response) -> logCount.incrementAndGet();
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    StatisticsHandler handlerChain = new StatisticsHandler();
    handlerChain.setHandler(requestLogHandler);

    Javalin app = Javalin.create()
        .port(0)
        .embeddedServer(new EmbeddedJettyFactory(() -> {
            Server server = new Server();
            server.setHandler(handlerChain);
            return server;
        }))
        .get("/", ctx -> ctx.result("Hello World"))
        .start();

    String origin = "http://localhost:" + app.port();

    int requests = 10;
    for (int i = 0; i < requests; i++) {
        assertThat(Unirest.get(origin + "/").asString().getBody(), is("Hello World"));
        assertThat(Unirest.get(origin + "/not_there").asString().getStatus(), is(404));
    }

    assertThat(handlerChain.getDispatched(), is(requests * 2));
    assertThat(handlerChain.getResponses2xx(), is(requests));
    assertThat(handlerChain.getResponses4xx(), is(requests));

    assertThat(logCount.get(), is((long) (requests * 2)));

    app.stop();
}
 
開發者ID:tipsy,項目名稱:javalin,代碼行數:36,代碼來源:TestCustomJetty.java

示例11: getHandlerCollection

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
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;
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:32,代碼來源:JettyHttpServer.java

示例12: setupHandler

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
private HandlerCollection setupHandler() throws Exception {
    final ResourceConfig resourceConfig = setupResourceConfig();
    final ServletContainer servlet = new ServletContainer(resourceConfig);

    final ServletHolder jerseyServlet = new ServletHolder(servlet);
    // Initialize and register Jersey ServletContainer

    jerseyServlet.setInitOrder(1);

    // statically provide injector to jersey application.
    final ServletContextHandler context =
        new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
    context.setContextPath("/");

    GzipHandler gzip = new GzipHandler();
    gzip.setIncludedMethods("POST");
    gzip.setMinGzipSize(860);
    gzip.setIncludedMimeTypes("application/json");
    context.setGzipHandler(gzip);

    context.addServlet(jerseyServlet, "/*");
    context.addFilter(new FilterHolder(new ShutdownFilter(stopping, mapper)), "/*", null);
    context.setErrorHandler(new JettyJSONErrorHandler(mapper));

    final RequestLogHandler requestLogHandler = new RequestLogHandler();

    requestLogHandler.setRequestLog(new Slf4jRequestLog());

    final RewriteHandler rewrite = new RewriteHandler();
    makeRewriteRules(rewrite);

    final HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[]{rewrite, context, requestLogHandler});

    return handlers;
}
 
開發者ID:spotify,項目名稱:heroic,代碼行數:37,代碼來源:HttpServer.java

示例13: apply

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
@Override
public HandlerCollection apply(Environment environment) {
  HandlerCollection handlers = new HandlerCollection();
  List<RequestLogHandler> requestLogHandlers = createRequestLogHandlers(environment);
  Collection<ServletContextHandler> servletContextHandlers = createServletContexts(environment);
  Collection<ContextHandler> contextHandlers = createContextHandlers(environment);

  ContextHandlerCollection contexts = new ContextHandlerCollection();
  addContextHandlers(contexts, servletContextHandlers);
  addContextHandlers(contexts, contextHandlers);
  if (contexts.getHandlers() != null && contexts.getHandlers().length > 0) {
    handlers.addHandler(contexts);
  }

  // Shutdown Handler of Jetty
  ShutdownHandler shutdownHandler = createShutdownHandler(environment);
  if (shutdownHandler != null) {
    handlers.addHandler(shutdownHandler);
  }

  // Log handlers are created the first but processed the
  // last. In case there is an access log handler, the HTTP
  // response codes should be correct.
  addHandlers(handlers, requestLogHandlers);

  return handlers;
}
 
開發者ID:sdl,項目名稱:embedded-rest-server,代碼行數:28,代碼來源:HandlerCollectionLoader.java

示例14: apply

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
@Override
public List<RequestLogHandler> apply(Environment environment) {
  Iterable<RequestLogHandlerFactory> loader = loadFactories();
  List<RequestLogHandler> handlers = new ArrayList<>();
  for (RequestLogHandlerFactory factory : loader) {
    RequestLogHandler requestLogHandler = createRequestLogHandler(factory, environment);
    if (requestLogHandler != null) {
      handlers.add(requestLogHandler);
    }
  }
  return handlers;
}
 
開發者ID:sdl,項目名稱:embedded-rest-server,代碼行數:13,代碼來源:RequestLogHandlerFactoryLoader.java

示例15: main

import org.eclipse.jetty.server.handler.RequestLogHandler; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    WebAppMain.standAloneMode = true;
    Logo.print(true);

    initializeLogDir();

    final ConfigureAdaptor conf = ConfigureManager.getConfigure();
    connectScouterCollector();

    final Server server = new Server(conf.getNetHttpPort());

    HandlerCollection handlers = new HandlerCollection();

    RequestLogHandler requestLogHandler = setRequestLogHandler();
    handlers.addHandler(requestLogHandler);

    ServletContextHandler servletContextHandler = setWebAppContext();
    handlers.addHandler(servletContextHandler);

    server.setHandler(handlers);

    try {
        server.start();
        waitOnExit(server);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:scouter-project,項目名稱:scouter,代碼行數:29,代碼來源:WebAppMain.java


注:本文中的org.eclipse.jetty.server.handler.RequestLogHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。