I can access the controller in web browser, but I can't see its mapping message in the console log. Normally when spring boot app starts, the eclipse console should print out the mapped controller and the accessing url, why didn't I see it?
I have already added the logging.level.org.springframework.web=DEBUG
to application.properties file, but it does not help.
Updated: This is my pom.xml
file:
<modelVersion>4.0.0</modelVersion>
<groupId>com.yp</groupId>
<artifactId>BootTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BootTest</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
The snippet of console log when app starts
Is there any way to show up mapped controller info when app starts?
please view Spring Boot 2.1 Release Notes#logging-refinements
Spring Framework 5.1 revisited the debug logging output while working on web applications (Spring MVC or Spring WebFlux). If you are trying to debug an application and you want to restore Spring Boot 2.0 style logging you should add the following to your application.properties:
logging.level.web=debug
You might also want to set
spring.http.log-request-details
to true to log actual request details. By default this property is false as it can potentially expose sensitive information.
只需在 eclipse VM 参数中添加这个-Ddebug
,详细的调试日志就会开始打印。
As mentioned by Andy Wilkinson there has been a lot of overhaul especially in terms of logging. The commit removed the log.
If you wish to see this information, you can change the logging level to TRACE instead of falling back to a previous version
logging.level.org.springframework.web: TRACE
就像 Andy Wilkinson 的评论帖子所说的,我使用的是 spring boot 2.1,当我将 spring boot 版本更改为旧版本时,此问题不会再次发生。
If only want to see controller mapping log. Try to set TRACE to RequestMappingHandlerMapping to prevent too much log.
logging.level.org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping=TRACE
# spring boot 2.2.4
I like this answer and I think that' what I want. Just see what apis is there while the application is running.
logging.level.org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping=TRACE
and then you will see like this;
c.u.c.s.c.SmsAuthController:
{POST /api/sms/send-sms-auth-code}: sendSmsAuthCode(SmsCodeParam,HttpServletRequest)
2568 2020-10-08 22:09:41,227 TRACE [restartedMain] o.s.w.s.m.m.a.RequestMappingHandlerMapping/detectHandlerMethods
c.u.c.t.TestController:
{POST /api/test/api-retired-warning}: testApiRetiredWithWarning()
{POST /api/test/api-retired-error}: testApiRetiredWithError()
{POST /api/test/api-test-only}: testApiTestOnly()、
2569 2020-10-08 22:09:41,228 TRACE [restartedMain] o.s.w.s.m.m.a
If you want to see info logs in eclipse just add following line to properties bootstrap.yml
logging:
level:
org.springframework: INFO
要获得更多日志记录, logging.level.root=DEBUG
在引导程序/应用程序属性文件中使用logging.level.root=DEBUG
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.