Allow lowercase logger level on MVC endpoint

See gh-7914
This commit is contained in:
Kazuki Shimizu 2017-01-09 05:12:18 +09:00 committed by Stephane Nicoll
parent de1d450af7
commit a6756c9ed3
2 changed files with 5 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);
}