当前位置: 首页>>代码示例>>Java>>正文


Java RequestLogHandler.setRequestLog方法代码示例

本文整理汇总了Java中org.eclipse.jetty.server.handler.RequestLogHandler.setRequestLog方法的典型用法代码示例。如果您正苦于以下问题:Java RequestLogHandler.setRequestLog方法的具体用法?Java RequestLogHandler.setRequestLog怎么用?Java RequestLogHandler.setRequestLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jetty.server.handler.RequestLogHandler的用法示例。


在下文中一共展示了RequestLogHandler.setRequestLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: getRequestLogHandler

import org.eclipse.jetty.server.handler.RequestLogHandler; //导入方法依赖的package包/类
private Handler getRequestLogHandler(Handler handler) {
    RequestLog requestLog = new Log4JAccessLog(configuration.getAccessLogConfigFilePath(),
            () -> configuration.isAccessLogEnabled());
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    requestLogHandler.setHandler(handler);

    return requestLogHandler;
}
 
开发者ID:flipkart-incubator,项目名称:Poseidon,代码行数:10,代码来源:Poseidon.java

示例12: wrapJettyHandler

import org.eclipse.jetty.server.handler.RequestLogHandler; //导入方法依赖的package包/类
/**
 * Wraps the Jetty handler.
 *
 * @param server the Jetty server.
 */
private void wrapJettyHandler(Server server) {
    LogbackAccessJettyRequestLog requestLog = new LogbackAccessJettyRequestLog(
            logbackAccessProperties, environment, applicationEventPublisher);
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setHandler(server.getHandler());
    requestLogHandler.setRequestLog(requestLog);
    server.setHandler(requestLogHandler);
}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:14,代码来源:JettyLogbackAccessInstaller.java

示例13: main

import org.eclipse.jetty.server.handler.RequestLogHandler; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
       // Create a basic jetty server object that will listen on port 8080.  Note that if you set this to port 0
       // then a randomly available port will be assigned that you can either look in the logs for the port,
       // or programmatically obtain it for use in test cases.
       Server server = new Server(8080);
	HandlerCollection handlers = new HandlerCollection();
	server.setHandler(handlers);

       ServletHandler servlet = new ServletHandler();
	servlet.addServletWithMapping(HelloServlet.class, "/*");
	handlers.addHandler(servlet);

	handlers.addHandler(new DefaultHandler()); // must be after servlet it seems

	// log using NCSA (common log format)
	// http://en.wikipedia.org/wiki/Common_Log_Format
	NCSARequestLog requestLog = new NCSARequestLog();
	requestLog.setFilename("/tmp/yyyy_mm_dd.request.log");
	requestLog.setFilenameDateFormat("yyyy_MM_dd");
	requestLog.setRetainDays(90);
	requestLog.setAppend(true);
	requestLog.setExtended(true);
	requestLog.setLogCookies(false);
	requestLog.setLogTimeZone("GMT");
	RequestLogHandler requestLogHandler = new RequestLogHandler();
	requestLogHandler.setRequestLog(requestLog);
	handlers.addHandler(requestLogHandler);

	// Start things up! By using the server.join() the server thread will join with the current thread.
	// See "http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#join()" for more details.
	server.start();
	server.join();
}
 
开发者ID:parrt,项目名称:cs601,代码行数:34,代码来源:MinimalServletsWithLogging.java

示例14: providesRequestLogHandler

import org.eclipse.jetty.server.handler.RequestLogHandler; //导入方法依赖的package包/类
@Provides
@Singleton
@Inject
protected RequestLogHandler providesRequestLogHandler(RequestLog requestLog) {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    requestLogHandler.setRequestLog(requestLog);
    return requestLogHandler;
}
 
开发者ID:diptanu,项目名称:Artemis,代码行数:9,代码来源:ServerModule.java

示例15: WebServer

import org.eclipse.jetty.server.handler.RequestLogHandler; //导入方法依赖的package包/类
public WebServer(@NotNull SharedContext context, @Nullable Server server, @NotNull WebServerConfig config, @NotNull EncryptionFactory tokenFactory) {
  this.context = context;
  this.server = server;
  this.config = config;
  this.tokenFactory = tokenFactory;
  if (server != null) {
    final ServletContextHandler contextHandler = new ServletContextHandler();
    contextHandler.setContextPath("/");
    handler = contextHandler.getServletHandler();

    //final ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
    //securityHandler.addConstraintMapping(new );
    //contextHandler.setSecurityHandler(securityHandler);

    final RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new RequestLog() {
      @Override
      public void log(Request request, Response response) {
        final User user = (User) request.getAttribute(User.class.getName());
        final String userName = (user == null || user.isAnonymous()) ? "" : user.getUserName();
        log.info("{}:{} - {} - \"{} {}\" {} {}", request.getRemoteHost(), request.getRemotePort(), userName, request.getMethod(), request.getHttpURI(), response.getStatus(), response.getReason());
      }
    });

    final HandlerCollection handlers = new HandlerCollection();
    handlers.addHandler(contextHandler);
    handlers.addHandler(logHandler);
    server.setHandler(handlers);
  } else {
    handler = null;
  }
}
 
开发者ID:bozaro,项目名称:git-as-svn,代码行数:33,代码来源:WebServer.java


注:本文中的org.eclipse.jetty.server.handler.RequestLogHandler.setRequestLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。