本文整理汇总了Java中ch.qos.logback.access.jetty.RequestLogImpl类的典型用法代码示例。如果您正苦于以下问题:Java RequestLogImpl类的具体用法?Java RequestLogImpl怎么用?Java RequestLogImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestLogImpl类属于ch.qos.logback.access.jetty包,在下文中一共展示了RequestLogImpl类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: jettyConfigBean
import ch.qos.logback.access.jetty.RequestLogImpl; //导入依赖的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: jettyConfigBean
import ch.qos.logback.access.jetty.RequestLogImpl; //导入依赖的package包/类
/**
* @return Jetty config bean
*/
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
jef.addServerCustomizers(new JettyServerCustomizer() {
public void customize(Server server) {
if (Config.getConfigBoolean("access_log_enabled", true)) {
// enable access log via Logback
HandlerCollection handlers = new HandlerCollection();
for (Handler handler : server.getHandlers()) {
handlers.addHandler(handler);
}
RequestLogHandler reqLogs = new RequestLogHandler();
reqLogs.setServer(server);
RequestLogImpl rli = new RequestLogImpl();
rli.setResource("/logback-access.xml");
rli.setQuiet(true);
rli.start();
reqLogs.setRequestLog(rli);
handlers.addHandler(reqLogs);
server.setHandler(handlers);
}
for (Connector y : server.getConnectors()) {
for (ConnectionFactory cf : y.getConnectionFactories()) {
if (cf instanceof HttpConnectionFactory) {
HttpConnectionFactory dcf = (HttpConnectionFactory) cf;
// support for X-Forwarded-Proto
// redirect back to https if original request uses it
if (Config.IN_PRODUCTION) {
HttpConfiguration httpConfiguration = dcf.getHttpConfiguration();
httpConfiguration.addCustomizer(new ForwardedRequestCustomizer());
}
// Disable Jetty version header
dcf.getHttpConfiguration().setSendServerVersion(false);
}
}
}
}
});
int defaultPort = NumberUtils.toInt(System.getProperty("jetty.http.port", "8080"));
jef.setPort(NumberUtils.toInt(System.getProperty("server.port"), defaultPort));
logger.info("Listening on port {}...", jef.getPort());
return jef;
}