use of org.eclipse.jetty.server.NCSARequestLog in project scheduling by ow2-proactive.
the class JettyStarter method deployWebApplications.
public List<String> deployWebApplications(String rmUrl, String schedulerUrl) {
initializeRestProperties();
setSystemPropertyIfNotDefined("rm.url", rmUrl);
setSystemPropertyIfNotDefined("scheduler.url", schedulerUrl);
System.setProperty(CentralPAPropertyRepository.JAVAX_XML_TRANSFORM_TRANSFORMERFACTORY.getName(), DEFAULT_XML_TRANSFORMER);
if (WebProperties.WEB_DEPLOY.getValueAsBoolean()) {
logger.info("Starting the web applications...");
int httpPort = getJettyHttpPort();
int httpsPort = 443;
if (WebProperties.WEB_HTTPS_PORT.isSet()) {
httpsPort = WebProperties.WEB_HTTPS_PORT.getValueAsInt();
}
boolean httpsEnabled = WebProperties.WEB_HTTPS.getValueAsBoolean();
boolean redirectHttpToHttps = WebProperties.WEB_REDIRECT_HTTP_TO_HTTPS.getValueAsBoolean();
int restPort = httpPort;
String httpProtocol;
String[] defaultVirtualHost;
String[] httpVirtualHost = new String[] { "@" + HTTP_CONNECTOR_NAME };
if (httpsEnabled) {
httpProtocol = "https";
defaultVirtualHost = new String[] { "@" + HTTPS_CONNECTOR_NAME };
restPort = httpsPort;
} else {
defaultVirtualHost = httpVirtualHost;
httpProtocol = "http";
}
Server server = createHttpServer(httpPort, httpsPort, httpsEnabled, redirectHttpToHttps);
server.setStopAtShutdown(true);
HandlerList topLevelHandlerList = new HandlerList();
if (httpsEnabled && redirectHttpToHttps) {
ContextHandler redirectHandler = new ContextHandler();
redirectHandler.setContextPath("/");
redirectHandler.setHandler(new SecuredRedirectHandler());
redirectHandler.setVirtualHosts(httpVirtualHost);
topLevelHandlerList.addHandler(redirectHandler);
}
topLevelHandlerList.addHandler(createSecurityHeadersHandler());
if (WebProperties.JETTY_LOG_FILE.isSet()) {
String pathToJettyLogFile = FileStorageSupportFactory.relativeToHomeIfNotAbsolute(WebProperties.JETTY_LOG_FILE.getValueAsString());
File jettyLogFile = new File(pathToJettyLogFile);
if (!jettyLogFile.getParentFile().exists() && !jettyLogFile.getParentFile().mkdirs()) {
logger.error("Could not create jetty log file in: " + WebProperties.JETTY_LOG_FILE.getValueAsString());
} else {
NCSARequestLog requestLog = new NCSARequestLog(pathToJettyLogFile);
requestLog.setAppend(true);
requestLog.setExtended(false);
requestLog.setLogTimeZone("GMT");
requestLog.setLogLatency(true);
requestLog.setRetainDays(WebProperties.JETTY_LOG_RETAIN_DAYS.getValueAsInt());
RequestLogHandler requestLogHandler = new RequestLogHandler();
requestLogHandler.setRequestLog(requestLog);
topLevelHandlerList.addHandler(requestLogHandler);
}
}
RewriteHandler rewriteHandler = null;
HandlerList contextHandlerList = null;
if (WebProperties.WEB_PCA_PROXY_REWRITE_ENABLED.getValueAsBoolean()) {
rewriteHandler = new RewriteHandler();
PCAProxyRule proxyRule = new PCAProxyRule();
rewriteHandler.addRule(proxyRule);
rewriteHandler.setRewriteRequestURI(true);
rewriteHandler.setRewritePathInfo(false);
rewriteHandler.setOriginalPathAttribute(PCAProxyRule.originalPathAttribute);
rewriteHandler.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC);
contextHandlerList = new HandlerList();
} else {
contextHandlerList = topLevelHandlerList;
}
addWarsToHandlerList(contextHandlerList, defaultVirtualHost);
if (WebProperties.WEB_PCA_PROXY_REWRITE_ENABLED.getValueAsBoolean()) {
rewriteHandler.setHandler(contextHandlerList);
topLevelHandlerList.addHandler(rewriteHandler);
}
server.setHandler(topLevelHandlerList);
if (logger.isDebugEnabled()) {
server.setDumpAfterStart(true);
}
String schedulerHost = ProActiveInet.getInstance().getHostname();
return startServer(server, schedulerHost, restPort, httpProtocol);
}
return new ArrayList<>();
}
use of org.eclipse.jetty.server.NCSARequestLog 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;
}
Aggregations