Merge branch '1.5.x'
This commit is contained in:
commit
bbea134e1c
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ content into your application; rather pick only the properties that you need.
|
|||
server.tomcat.accesslog.pattern=common # Format pattern for access logs.
|
||||
server.tomcat.accesslog.prefix=access_log # Log file name prefix.
|
||||
server.tomcat.accesslog.rename-on-rotate=false # Defer inclusion of the date stamp in the file name until rotate time.
|
||||
server.tomcat.accesslog.rotate=true # Enable access log rotation.
|
||||
server.tomcat.accesslog.suffix=.log # Log file name suffix.
|
||||
server.tomcat.background-processor-delay=30 # Delay in seconds between the invocation of backgroundProcess methods.
|
||||
server.tomcat.basedir= # Tomcat base directory. If not specified a temporary directory will be used.
|
||||
|
|
@ -221,6 +222,7 @@ content into your application; rather pick only the properties that you need.
|
|||
server.undertow.accesslog.enabled=false # Enable access log.
|
||||
server.undertow.accesslog.pattern=common # Format pattern for access logs.
|
||||
server.undertow.accesslog.prefix=access_log. # Log file name prefix.
|
||||
server.undertow.accesslog.rotate=true # Enable access log rotation.
|
||||
server.undertow.accesslog.suffix=log # Log file name suffix.
|
||||
server.undertow.buffer-size= # Size of each buffer in bytes.
|
||||
server.undertow.buffers-per-region= # Number of buffer per region.
|
||||
|
|
|
|||
|
|
@ -126,6 +126,8 @@ public class UndertowEmbeddedServletContainerFactory
|
|||
|
||||
private boolean accessLogEnabled = false;
|
||||
|
||||
private boolean accessLogRotate = true;
|
||||
|
||||
private boolean useForwardHeaders;
|
||||
|
||||
/**
|
||||
|
|
@ -411,7 +413,7 @@ public class UndertowEmbeddedServletContainerFactory
|
|||
: "access_log.");
|
||||
AccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver(
|
||||
createWorker(), this.accessLogDirectory, prefix,
|
||||
this.accessLogSuffix);
|
||||
this.accessLogSuffix, this.accessLogRotate);
|
||||
String formatString = (this.accessLogPattern != null) ? this.accessLogPattern
|
||||
: "common";
|
||||
return new AccessLogHandler(handler, accessLogReceiver, formatString,
|
||||
|
|
@ -584,6 +586,10 @@ public class UndertowEmbeddedServletContainerFactory
|
|||
return this.accessLogEnabled;
|
||||
}
|
||||
|
||||
public void setAccessLogRotate(boolean accessLogRotate) {
|
||||
this.accessLogRotate = accessLogRotate;
|
||||
}
|
||||
|
||||
protected final boolean isUseForwardHeaders() {
|
||||
return this.useForwardHeaders;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue