diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java index 931fa5adb5..0fcf476891 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java @@ -156,7 +156,7 @@ public class JettyWebServer implements WebServer { this.started = true; JettyWebServer.logger .info("Jetty started on port(s) " + getActualPortsDescription() - + " with context path " + getContextPath()); + + " with context path '" + getContextPath() + "'"); } catch (WebServerException ex) { throw ex; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java index 33942f070a..85e79d062f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java @@ -195,7 +195,7 @@ public class TomcatWebServer implements WebServer { this.started = true; TomcatWebServer.logger .info("Tomcat started on port(s): " + getPortsDescription(true) - + " with context path " + getContextPath()); + + " with context path '" + getContextPath() + "'"); } catch (ConnectorStartFailedException ex) { stopSilently(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java index 518ef52f00..1c9bd97991 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java @@ -158,7 +158,7 @@ public class UndertowServletWebServer implements WebServer { this.started = true; UndertowServletWebServer.logger .info("Undertow started on port(s) " + getPortsDescription() - + " with context path " + this.contextPath); + + " with context path '" + this.contextPath + "'"); } catch (Exception ex) { try { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index ca779a44c4..b08c996757 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -263,6 +263,15 @@ public abstract class AbstractServletWebServerFactoryTests { assertThat(getResponse(getLocalUrl("/say/hello"))).isEqualTo("Hello World"); } + @Test + public void contextPathIsLoggedOnStartup() { + AbstractServletWebServerFactory factory = getFactory(); + factory.setContextPath("/custom"); + this.webServer = factory.getWebServer(exampleServletRegistration()); + this.webServer.start(); + assertThat(this.output.toString()).containsOnlyOnce("with context path '/custom'"); + } + @Test public void contextPathMustStartWithSlash() throws Exception { this.thrown.expect(IllegalArgumentException.class);