本文整理汇总了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;
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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()]));
}
}
示例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;
}
示例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;
}
示例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);
});
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}