Spring MVC 未显示Spring应用程序的日志

8ehkhllq  于 2022-11-14  发布在  Spring
关注(0)|答案(1)|浏览(173)

我在我的应用程序中使用slf4j logger。但是我看不到控制台中的日志
这是我的应用程序类

@SpringBootApplication
public class InternalReplacerServiceApplication {
public static void main(String[] args) {
    SpringApplication.run(InternalReplacerServiceApplication.class, args);
    Logger LOG = LoggerFactory.getLogger(InternalReplacerServiceApplication.class);
    LOG.debug("inside app");
}
}

当我运行应用程序时,这些是我看到的日志

022-08-29 13:00:21.570  INFO 17420 --- [  restartedMain] c.j.j.InternalReplacerServiceApplication : Starting InternalReplacerServiceApplication using Java 17.0.4 on W10-lTkFoL0JX1t with PID 17420 (C:\Users\wgupta\Backend\internal_replacer_service\target\classes started by wgupta in C:\Users\wgupta\Backend\internal_replacer_service)
2022-08-29 13:00:21.572  INFO 17420 --- [  restartedMain] c.j.j.InternalReplacerServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-08-29 13:00:21.648  INFO 17420 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-08-29 13:00:21.648  INFO 17420 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-08-29 13:00:22.480  INFO 17420 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode
2022-08-29 13:00:22.484  INFO 17420 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2022-08-29 13:00:22.519  INFO 17420 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 15 ms. Found 0 Redis repository interfaces.
2022-08-29 13:00:23.409  INFO 17420 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8081 (http)
2022-08-29 13:00:23.430  INFO 17420 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-08-29 13:00:23.431  INFO 17420 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.64]
2022-08-29 13:00:23.559  INFO 17420 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-08-29 13:00:23.559  INFO 17420 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1910 ms
2022-08-29 13:00:24.807  INFO 17420 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2022-08-29 13:00:24.861  INFO 17420 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8081 (http) with context path ''
2022-08-29 13:00:24.879  INFO 17420 --- [  restartedMain] c.j.j.InternalReplacerServiceApplication : Started InternalReplacerServiceApplication in 3.832 seconds (JVM running for 4.524)

这是应用程序属性

server.port=8081
# Redis Config
spring.cache.type=redis
spring.redis.host=127.0.0.1
spring.redis.port=6379

这是pom.xml依赖项

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.lindstrom</groupId>
        <artifactId>m3u8-parser</artifactId>
        <version>0.22</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20180813</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        </dependency>
    <!--    Parameter names -->
    <dependency>
        <groupId>com.fasterxml.jackson.module</groupId>
        <artifactId>jackson-module-parameter-names</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.datatype</groupId>
        <artifactId>jackson-datatype-jdk8</artifactId>
    </dependency>
</dependencies>
cnwbcb6i

cnwbcb6i1#

正如Dirk提到的,默认级别是INFO。
您可以在www.example.com中为记录器启用调试application.properties:

logging.level.com.example=debug

其中com.example是记录器的名称。

相关问题