eclipse spring boot 2.x 控制台日志不打印映射的控制器信息 [英] eclipse spring boot 2.x console log does not print mapped controller info

查看:51
本文介绍了eclipse spring boot 2.x 控制台日志不打印映射的控制器信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在 Web 浏览器中访问控制器,但在控制台日志中看不到它的映射消息.正常情况下,spring boot app启动的时候eclipse控制台应该会打印出映射的控制器和访问的url,为什么我没看到?

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?

我已经将 logging.level.org.springframework.web=DEBUG 添加到 application.properties 文件中,但它没有帮助.

I have already added the logging.level.org.springframework.web=DEBUG to application.properties file, but it does not help.

更新:这是我的 pom.xml 文件:

<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>

应用启动时的控制台日志片段

有没有办法在应用启动时显示映射的控制器信息?

Is there any way to show up mapped controller info when app starts?

推荐答案

请查看Spring Boot 2.1 发行说明#logging-refinements

Spring Framework 5.1 在处理 Web 应用程序(Spring MVC 或 Spring WebFlux)时重新审视了调试日志输出.如果您正在尝试调试应用程序并且想要恢复 Spring Boot 2.0 样式的日志记录,您应该将以下内容添加到您的 application.properties:

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

您可能还想将 spring.http.log-request-details 设置为 true 以记录实际的请求详细信息.默认情况下,此属性为 false,因为它可能会暴露敏感信息.

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 spring boot 2.x 控制台日志不打印映射的控制器信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆