From a6756c9ed3fa78fb234d886474c5e59d7cd37732 Mon Sep 17 00:00:00 2001 From: Kazuki Shimizu Date: Mon, 9 Jan 2017 05:12:18 +0900 Subject: [PATCH 1/2] Allow lowercase logger level on MVC endpoint See gh-7914 --- .../boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java | 3 ++- .../boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java index 9fa355aba3..dcb00036c9 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java @@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.ResponseBody; * Adapter to expose {@link LoggersEndpoint} as an {@link MvcEndpoint}. * * @author Ben Hale + * @author Kazuki Shimizu * @since 1.5.0 */ @ConfigurationProperties(prefix = "endpoints.loggers") @@ -71,7 +72,7 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { return getDisabledResponse(); } String level = configuration.get("configuredLevel"); - this.delegate.setLogLevel(name, level == null ? null : LogLevel.valueOf(level)); + this.delegate.setLogLevel(name, level == null ? null : LogLevel.valueOf(level.toUpperCase())); return HttpEntity.EMPTY; } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java index 5b9edcf5d6..7f80cc675c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java @@ -1,5 +1,6 @@ /* * Copyright 2012-2017 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +63,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @author Ben Hale * @author Phillip Webb + * @author Kazuki Shimizu */ @RunWith(SpringRunner.class) @SpringBootTest @@ -131,7 +133,7 @@ public class LoggersMvcEndpointTests { @Test public void setLoggerShouldSetLogLevel() throws Exception { this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) - .content("{\"configuredLevel\":\"DEBUG\"}")).andExpect(status().isOk()); + .content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk()); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); } From f21c7673567e5eaa94b1a665302c6365f2d7df91 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 15 Jan 2017 09:45:32 +0100 Subject: [PATCH 2/2] Polish contribution Closes gh-7914 --- .../boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java | 3 ++- .../boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java index dcb00036c9..af991d0f55 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java @@ -72,7 +72,8 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { return getDisabledResponse(); } String level = configuration.get("configuredLevel"); - this.delegate.setLogLevel(name, level == null ? null : LogLevel.valueOf(level.toUpperCase())); + LogLevel logLevel = level == null ? null : LogLevel.valueOf(level.toUpperCase()); + this.delegate.setLogLevel(name, logLevel); return HttpEntity.EMPTY; } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java index 7f80cc675c..63eea415be 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java @@ -1,6 +1,5 @@ /* * Copyright 2012-2017 the original author or authors. - * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +62,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @author Ben Hale * @author Phillip Webb - * @author Kazuki Shimizu */ @RunWith(SpringRunner.class) @SpringBootTest