Merge branch '1.5.x'
This commit is contained in:
@@ -956,6 +956,7 @@ public class ServerProperties
|
||||
valve.setPrefix(this.accesslog.getPrefix());
|
||||
valve.setSuffix(this.accesslog.getSuffix());
|
||||
valve.setRenameOnRotate(this.accesslog.isRenameOnRotate());
|
||||
valve.setRotatable(this.accesslog.isRotate());
|
||||
factory.addEngineValves(valve);
|
||||
}
|
||||
|
||||
@@ -1000,6 +1001,11 @@ public class ServerProperties
|
||||
*/
|
||||
private String suffix = ".log";
|
||||
|
||||
/**
|
||||
* Enable access log rotation.
|
||||
*/
|
||||
private boolean rotate = true;
|
||||
|
||||
/**
|
||||
* Defer inclusion of the date stamp in the file name until rotate time.
|
||||
*/
|
||||
@@ -1045,6 +1051,14 @@ public class ServerProperties
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public boolean isRotate() {
|
||||
return this.rotate;
|
||||
}
|
||||
|
||||
public void setRotate(boolean rotate) {
|
||||
this.rotate = rotate;
|
||||
}
|
||||
|
||||
public boolean isRenameOnRotate() {
|
||||
return this.renameOnRotate;
|
||||
}
|
||||
@@ -1296,21 +1310,14 @@ public class ServerProperties
|
||||
if (this.directBuffers != null) {
|
||||
factory.setDirectBuffers(this.directBuffers);
|
||||
}
|
||||
if (this.accesslog.dir != null) {
|
||||
factory.setAccessLogDirectory(this.accesslog.dir);
|
||||
}
|
||||
if (this.accesslog.pattern != null) {
|
||||
factory.setAccessLogPattern(this.accesslog.pattern);
|
||||
}
|
||||
if (this.accesslog.prefix != null) {
|
||||
factory.setAccessLogPrefix(this.accesslog.prefix);
|
||||
}
|
||||
if (this.accesslog.suffix != null) {
|
||||
factory.setAccessLogSuffix(this.accesslog.suffix);
|
||||
}
|
||||
if (this.accesslog.enabled != null) {
|
||||
factory.setAccessLogEnabled(this.accesslog.enabled);
|
||||
}
|
||||
factory.setAccessLogDirectory(this.accesslog.dir);
|
||||
factory.setAccessLogPattern(this.accesslog.pattern);
|
||||
factory.setAccessLogPrefix(this.accesslog.prefix);
|
||||
factory.setAccessLogSuffix(this.accesslog.suffix);
|
||||
factory.setAccessLogRotate(this.accesslog.rotate);
|
||||
factory.setUseForwardHeaders(serverProperties.getOrDeduceUseForwardHeaders());
|
||||
if (serverProperties.getMaxHttpHeaderSize() > 0) {
|
||||
customizeMaxHttpHeaderSize(factory,
|
||||
@@ -1393,6 +1400,11 @@ public class ServerProperties
|
||||
*/
|
||||
private File dir = new File("logs");
|
||||
|
||||
/**
|
||||
* Enable access log rotation.
|
||||
*/
|
||||
private boolean rotate = true;
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
@@ -1433,6 +1445,13 @@ public class ServerProperties
|
||||
this.dir = dir;
|
||||
}
|
||||
|
||||
public boolean isRotate() {
|
||||
return this.rotate;
|
||||
}
|
||||
|
||||
public void setRotate(boolean rotate) {
|
||||
this.rotate = rotate;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ public class ServerPropertiesTests {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("server.tomcat.accesslog.pattern", "%h %t '%r' %s %b");
|
||||
map.put("server.tomcat.accesslog.prefix", "foo");
|
||||
map.put("server.tomcat.accesslog.rotate", "false");
|
||||
map.put("server.tomcat.accesslog.rename-on-rotate", "true");
|
||||
map.put("server.tomcat.accesslog.suffix", "-bar.log");
|
||||
map.put("server.tomcat.protocol_header", "X-Forwarded-Protocol");
|
||||
@@ -147,6 +148,7 @@ public class ServerPropertiesTests {
|
||||
ServerProperties.Tomcat tomcat = this.properties.getTomcat();
|
||||
assertThat(tomcat.getAccesslog().getPattern()).isEqualTo("%h %t '%r' %s %b");
|
||||
assertThat(tomcat.getAccesslog().getPrefix()).isEqualTo("foo");
|
||||
assertThat(tomcat.getAccesslog().isRotate()).isFalse();
|
||||
assertThat(tomcat.getAccesslog().isRenameOnRotate()).isTrue();
|
||||
assertThat(tomcat.getAccesslog().getSuffix()).isEqualTo("-bar.log");
|
||||
assertThat(tomcat.getRemoteIpHeader()).isEqualTo("Remote-Ip");
|
||||
@@ -464,6 +466,28 @@ public class ServerPropertiesTests {
|
||||
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customizeUndertowAccessLog() {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
map.put("server.undertow.accesslog.enabled", "true");
|
||||
map.put("server.undertow.accesslog.pattern", "foo");
|
||||
map.put("server.undertow.accesslog.prefix", "test_log");
|
||||
map.put("server.undertow.accesslog.suffix", "txt");
|
||||
map.put("server.undertow.accesslog.dir", "test-logs");
|
||||
map.put("server.undertow.accesslog.rotate", "false");
|
||||
bindProperties(map);
|
||||
|
||||
UndertowEmbeddedServletContainerFactory container = spy(
|
||||
new UndertowEmbeddedServletContainerFactory());
|
||||
this.properties.getUndertow().customizeUndertow(this.properties, container);
|
||||
verify(container).setAccessLogEnabled(true);
|
||||
verify(container).setAccessLogPattern("foo");
|
||||
verify(container).setAccessLogPrefix("test_log");
|
||||
verify(container).setAccessLogSuffix("txt");
|
||||
verify(container).setAccessLogDirectory(new File("test-logs"));
|
||||
verify(container).setAccessLogRotate(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultUseForwardHeadersUndertow() throws Exception {
|
||||
UndertowEmbeddedServletContainerFactory container = spy(
|
||||
|
||||
Reference in New Issue
Block a user