Add support for configuring Undertow's access log via the environment

This commit adds support for configuring Undertow's access log via the
environment using the following properties:

server.undertow.access-log-enabled
server.undertow.access-log-pattern
server.undertow.access-log-dir

See gh-3014
This commit is contained in:
Marcos Barbero
2015-05-19 16:18:10 -03:00
committed by Andy Wilkinson
parent 3eb5c348fb
commit 90e43737bb
5 changed files with 144 additions and 14 deletions

View File

@@ -56,6 +56,7 @@ import org.springframework.util.StringUtils;
* @author Stephane Nicoll
* @author Andy Wilkinson
* @author Ivan Sopov
* @author Marcos Barbero
*/
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = false)
public class ServerProperties implements EmbeddedServletContainerCustomizer, Ordered {
@@ -578,6 +579,21 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
private Boolean directBuffers;
/**
* Format pattern for access logs.
*/
private String accessLogPattern;
/**
* Enable access log.
*/
private boolean accessLogEnabled = false;
/**
* Undertow access log directory. If not specified a temporary directory will be used.
*/
private File accessLogDir;
public Integer getBufferSize() {
return this.bufferSize;
}
@@ -618,12 +634,39 @@ public class ServerProperties implements EmbeddedServletContainerCustomizer, Ord
this.directBuffers = directBuffers;
}
public String getAccessLogPattern() {
return accessLogPattern;
}
public void setAccessLogPattern(String accessLogPattern) {
this.accessLogPattern = accessLogPattern;
}
public boolean isAccessLogEnabled() {
return accessLogEnabled;
}
public void setAccessLogEnabled(boolean accessLogEnabled) {
this.accessLogEnabled = accessLogEnabled;
}
public File getAccessLogDir() {
return accessLogDir;
}
public void setAccessLogDir(File accessLogDir) {
this.accessLogDir = accessLogDir;
}
void customizeUndertow(UndertowEmbeddedServletContainerFactory factory) {
factory.setBufferSize(this.bufferSize);
factory.setBuffersPerRegion(this.buffersPerRegion);
factory.setIoThreads(this.ioThreads);
factory.setWorkerThreads(this.workerThreads);
factory.setDirectBuffers(this.directBuffers);
factory.setAccessLogDirectory(this.accessLogDir);
factory.setAccessLogPattern(this.accessLogPattern);
factory.setAccessLogEnabled(this.accessLogEnabled);
}
}