Test verification
After completing the above build, we start the sample application and access /test
the endpoint, we can see the following output in the console:
2017-01-31 22:34:57.123 INFO 16372 --- [nio-8000-exec-1] ication$$EnhancerBySpringCGLIB$$d2a0b1e2 : Logger Level :INFO
2017-01-31 22:34:57.124 ERROR 16372 --- [nio-8000-exec-1] ication$$EnhancerBySpringCGLIB$$d2a0b1e2 : Logger Level :ERROR
Since the default log level is INFO
, there is no output DEBUG
level content. Below we can try /logger
to adjust the log level through the endpoint DEBUG
, for example, send a POST request to the /loggers/com.didispace
endpoint, where the body content of the request body is:
{
"configuredLevel": "DEBUG"
}
Revisiting /test
the endpoint, we will see the following output in the console, /test
the log content defined in the endpoint DEBUG
is printed out:
2017-01-31 22:37:35.252 DEBUG 16372 --- [nio-8000-exec-5] ication$$EnhancerBySpringCGLIB$$d2a0b1e2 : Logger Level :DEBUG
2017-01-31 22:37:35.252 INFO 16372 --- [nio-8000-exec-5] ication$$EnhancerBySpringCGLIB$$d2a0b1e2 : Logger Level :INFO
2017-01-31 22:37:35.252 ERROR 16372 --- [nio-8000-exec-5] ication$$EnhancerBySpringCGLIB$$d2a0b1e2 : Logger Level :ERROR
As you can see, so far, we have not restarted the Spring Boot application, but simply /loggers
controlled the log level update by calling the endpoint. In addition to POST requests, we can also view the current log level settings through GET requests, such as: sending a GET request to an /loggers/com.didispace
endpoint, we will get com.didispace
the log level settings for the package:
{
"configuredLevel": "DEBUG",
"effectiveLevel": "DEBUG"
}
We can also get all the log level settings directly through GET request access without limiting the conditions. /loggers
The specific returns are not listed here, and readers can try it by themselves. source code