gpt4 book ai didi

java - Spring Boot Logback 记录 DEBUG 消息

转载 作者:行者123 更新时间:2023-12-04 20:15:14 25 4
gpt4 key购买 nike

当 Spring Boot 应该在 INFO 级别时,我在将 DEBUG 级别的日志项吐到终端时遇到问题。

logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT" />
</root>

<logger name="org.springframework.web" level="WARN"/>

</configuration>

pom.xml 中的依赖关系 (省略了与日志记录无关的所有内容)
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- Logging -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>

终端中不断出现的行
20:01:00.937 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [servletConfigInitParams]
20:01:00.937 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [servletContextInitParams]
20:01:00.937 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [systemProperties]
20:01:00.937 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [systemEnvironment]
20:01:00.937 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [random]
20:01:00.937 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [applicationConfig: [classpath:/application.properties]]
20:01:00.938 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [class path resource [sql.properties]]
20:01:00.938 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'serverServletmapping' in [localProperties]
20:01:00.938 [main] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Could not find key 'serverServletmapping' in any property source. Returning [null]
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [servletConfigInitParams] PropertySource with lowest search precedence
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [servletContextInitParams] PropertySource with lowest search precedence
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [systemProperties] PropertySource with lowest search precedence
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [systemEnvironment] PropertySource with lowest search precedence
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [random] PropertySource with lowest search precedence
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [applicationConfig: [classpath:/application.properties]] PropertySource with lowest search precedence
20:01:00.938 [main] DEBUG o.s.core.env.MutablePropertySources - Adding [class path resource [sql.properties]] PropertySource with lowest search precedence

最佳答案

看起来 logback 没有找到你的 logback.xml文件。请引用logback documentation on config file location .

Configuration files such as logback.groovy, logback-test.xml or logback.xml can be located directly under any folder declared in the class path. For example, if the class path reads c:/java/jdk15/lib/rt.jar;c:/mylibs/ then the logback.xml file should be located directly under c:/mylibs/, that is as c:/mylibs/logback.xml.

Placing it under a sub-folder of c:/mylibs/, say, c:/mylibs/other/, will not work.

For web-applications, configuration files can be placed directly under WEB-INF/classes/.

关于java - Spring Boot Logback 记录 DEBUG 消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29977512/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com